diff --git a/src/elogd.c b/src/elogd.c index 52765a73..b9b8ae02 100755 --- a/src/elogd.c +++ b/src/elogd.c @@ -26415,8 +26415,10 @@ void decode_post(char *logbook, LOGBOOK * lbs, const char *string, const char *b /* find next boundary */ pctmp = string; do { - while (*pctmp != '-') + while (*pctmp != '-' && pctmp < string + length) pctmp++; + if (pctmp == string + length) + return; if ((p = strstr(pctmp, boundary)) != NULL) { if (*(p - 1) == '-') p--; @@ -26481,8 +26483,10 @@ void decode_post(char *logbook, LOGBOOK * lbs, const char *string, const char *b /* find next boundary */ pctmp = string; do { - while (*pctmp != '-') + while (*pctmp != '-' && pctmp < string + length) pctmp++; + if (pctmp == string + length) + return; if ((p = strstr(pctmp, boundary)) != NULL) { if (*(p - 1) == '-') p--; @@ -28014,6 +28018,14 @@ void server_loop(void) break; } + if (strncmp(net_buffer, "POST", 4) == 0 && + len < header_length + content_length) { + if (verbose) + eprintf("Incomplete POST request\n"); + keep_alive = FALSE; + break; + } + /* now process HTTP request and put the result into the return_buffer */ if (process_http_request(net_buffer, i_conn)) {