Need to include message size in the maximum buffer calculation.

This commit is contained in:
nicm
2019-12-16 16:09:28 +00:00
parent eaa58d28dc
commit b4520aaf2c
2 changed files with 4 additions and 4 deletions

4
file.c
View File

@ -376,8 +376,8 @@ file_push(struct client_file *cf)
left = EVBUFFER_LENGTH(cf->buffer);
while (left != 0) {
sent = left;
if (sent > MAX_IMSGSIZE - IMSG_HEADER_SIZE)
sent = MAX_IMSGSIZE - IMSG_HEADER_SIZE;
if (sent > MAX_IMSGSIZE - IMSG_HEADER_SIZE - sizeof *msg)
sent = MAX_IMSGSIZE - IMSG_HEADER_SIZE - sizeof *msg;
msglen = (sizeof *msg) + sent;
msg = xrealloc(msg, msglen);