1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-03-10 16:58:47 +03:00

Fix a boundary condition in read_buffer in daemon-shared.c.

This commit is contained in:
Petr Rockai 2012-01-16 05:09:16 +00:00
parent d528658f97
commit 3556560b38

View File

@ -30,20 +30,19 @@ int read_buffer(int fd, char **buffer) {
if (result < 0 && errno != EAGAIN && errno != EWOULDBLOCK)
goto fail;
if ((!strncmp((*buffer) + bytes - 4, "\n##\n", 4))) {
*(*buffer + bytes - 4) = 0;
break; /* success, we have the full message now */
}
if (bytes == buffersize) {
buffersize += 1024;
if (!(new = realloc(*buffer, buffersize + 1)))
goto fail;
*buffer = new;
} else {
(*buffer)[bytes] = 0;
if ((end = strstr((*buffer) + bytes - 4, "\n##\n"))) {
*end = 0;
break; /* success, we have the full message now */
}
/* TODO call select here if we encountered EAGAIN/EWOULDBLOCK */
}
/* TODO call select here if we encountered EAGAIN/EWOULDBLOCK */
}
return 1;
fail: