--- libaitwww/src/aitwww.c 2012/03/09 12:47:06 1.1.1.1.2.4 +++ libaitwww/src/aitwww.c 2012/03/15 01:59:37 1.3 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: aitwww.c,v 1.1.1.1.2.4 2012/03/09 12:47:06 misho Exp $ +* $Id: aitwww.c,v 1.3 2012/03/15 01:59:37 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -99,14 +99,14 @@ www_initCGI(void) str = getenv("REQUEST_METHOD"); if (!str) { - www_SetErr(EBADMSG, "Request method not found"); + www_SetErr(EFAULT, "Request method not found"); return NULL; } if (!strcmp(str, "GET") || !strcmp(str, "HEAD")) { /* GET | HEAD */ str = getenv("QUERY_STRING"); if (!str) { - www_SetErr(EBADMSG, "Query string not found"); + www_SetErr(EFAULT, "Query string not found"); return NULL; } cgi = www_parseQuery(str); @@ -114,19 +114,19 @@ www_initCGI(void) /* POST */ str = getenv("CONTENT_LENGTH"); if (!str) { - www_SetErr(EBADMSG, "Content length not found"); + www_SetErr(EFAULT, "Content length not found"); return NULL; } else ctlen = strtol(str, NULL, 0); s = getenv("CONTENT_TYPE"); if (!s) { - www_SetErr(EBADMSG, "Content type not found"); + www_SetErr(EFAULT, "Content type not found"); return NULL; } if (www_cmp(s, "multipart/form-data") && www_cmp(s, "application/x-www-form-urlencoded")) { - www_SetErr(EBADMSG, "MIME parts are broken"); + www_SetErr(EFAULT, "MIME parts are broken"); return NULL; } @@ -135,7 +135,8 @@ www_initCGI(void) if (!str) { LOGERR; return NULL; - } + } else + memset(str, 0, ctlen + 1); for (i = 0; i < ctlen && (rlen = read(STDIN_FILENO, (void*) str + i, ctlen - i)) > 0; i += rlen); str[ctlen] = 0; @@ -148,7 +149,7 @@ www_initCGI(void) free(str); } else { /* Unknown method */ - www_SetErr(EBADMSG, "Unknown request method"); + www_SetErr(EFAULT, "Unknown request method"); return NULL; } @@ -532,6 +533,10 @@ www_parseMultiPart(const char *str, int ctlen, const c SLIST_FOREACH(m, mime, mime_node) { s = mime_getValue(m, "content-disposition"); attr = www_parseAttributes(&s); + if (!www_getAttribute(attr, "name")) { + www_freeAttributes(&attr); + continue; + } t = malloc(sizeof(struct tagCGI)); if (!t) {