summaryrefslogtreecommitdiff
path: root/src/common/socket.h
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2018-11-08 00:28:34 +0300
committerAndrei Karas <akaras@inbox.ru>2018-11-15 01:40:30 +0300
commite35402b608ace44f80928591bad388a0d5765184 (patch)
tree438bb794a8ba9d3888b83d0c4774e49b003c1689 /src/common/socket.h
parent3716e975e69e7e33714824f90c6520e5ce67014f (diff)
downloadhercules-e35402b608ace44f80928591bad388a0d5765184.tar.gz
hercules-e35402b608ace44f80928591bad388a0d5765184.tar.bz2
hercules-e35402b608ace44f80928591bad388a0d5765184.tar.xz
hercules-e35402b608ace44f80928591bad388a0d5765184.zip
Add validation for WFIFOHEAD buffer allocations.
Diffstat (limited to 'src/common/socket.h')
-rw-r--r--src/common/socket.h8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/common/socket.h b/src/common/socket.h
index 2d497ebfc..c5d0e224e 100644
--- a/src/common/socket.h
+++ b/src/common/socket.h
@@ -41,11 +41,7 @@ struct config_setting_t;
// socket I/O macros
#define RFIFOHEAD(fd)
-#define WFIFOHEAD(fd, size) \
- do{ \
- if ((fd) && sockt->session[fd]->wdata_size + (size) > sockt->session[fd]->max_wdata) \
- sockt->realloc_writefifo((fd), (size)); \
- } while(0)
+#define WFIFOHEAD(fd, size) sockt->wfifohead(fd, size)
#define RFIFOP(fd,pos) ((const void *)(sockt->session[fd]->rdata + sockt->session[fd]->rdata_pos + (pos)))
#define WFIFOP(fd,pos) ((void *)(sockt->session[fd]->wdata + sockt->session[fd]->wdata_size + (pos)))
@@ -132,6 +128,7 @@ struct socket_data {
size_t max_rdata, max_wdata;
size_t rdata_size, wdata_size;
size_t rdata_pos;
+ uint last_head_size;
time_t rdata_tick; // time of last recv (for detecting timeouts); zero when timeout is disabled
RecvFunc func_recv;
@@ -205,6 +202,7 @@ struct socket_interface {
int (*realloc_fifo) (int fd, unsigned int rfifo_size, unsigned int wfifo_size);
int (*realloc_writefifo) (int fd, size_t addition);
int (*wfifoset) (int fd, size_t len, bool validate);
+ void (*wfifohead) (int fd, size_t len);
int (*rfifoskip) (int fd, size_t len);
void (*close) (int fd);
void (*validateWfifo) (int fd, size_t len);