Fixed crash with incomplete attachments

SVN revision: 2174
This commit is contained in:
Stefan Ritt 2009-02-13 15:51:30 +00:00
parent 1c3a67ca38
commit 0773a09002

View File

@ -26415,8 +26415,10 @@ void decode_post(char *logbook, LOGBOOK * lbs, const char *string, const char *b
/* find next boundary */ /* find next boundary */
pctmp = string; pctmp = string;
do { do {
while (*pctmp != '-') while (*pctmp != '-' && pctmp < string + length)
pctmp++; pctmp++;
if (pctmp == string + length)
return;
if ((p = strstr(pctmp, boundary)) != NULL) { if ((p = strstr(pctmp, boundary)) != NULL) {
if (*(p - 1) == '-') if (*(p - 1) == '-')
p--; p--;
@ -26481,8 +26483,10 @@ void decode_post(char *logbook, LOGBOOK * lbs, const char *string, const char *b
/* find next boundary */ /* find next boundary */
pctmp = string; pctmp = string;
do { do {
while (*pctmp != '-') while (*pctmp != '-' && pctmp < string + length)
pctmp++; pctmp++;
if (pctmp == string + length)
return;
if ((p = strstr(pctmp, boundary)) != NULL) { if ((p = strstr(pctmp, boundary)) != NULL) {
if (*(p - 1) == '-') if (*(p - 1) == '-')
p--; p--;
@ -28014,6 +28018,14 @@ void server_loop(void)
break; 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 */ /* now process HTTP request and put the result into the return_buffer */
if (process_http_request(net_buffer, i_conn)) { if (process_http_request(net_buffer, i_conn)) {