CVS update: php3/functions

From: Date: Tue, 29 Jun 1999 19:19:03 +0000
Subject: CVS update: php3/functions
Groups: php.dev 
Request: Send a blank email to php-dev+get-7831@lists.php.net to get a copy of this message
Date: Tuesday June 29, 1999 @ 15:19 Author: jim Update of /repository/php3/functions In directory php:/tmp/cvs-serv24222/functions Modified Files: post.c Log Message: Access to POST data of an unknown content-type. Barely tested. Index: php3/functions/post.c diff -u php3/functions/post.c:1.122 php3/functions/post.c:1.123 --- php3/functions/post.c:1.122 Tue Jun 1 08:44:48 1999 +++ php3/functions/post.c Tue Jun 29 15:19:03 1999 @@ -141,6 +141,7 @@ #endif int length, cnt; int file_upload = 0; + int unknown_content_type = 0; char *mb; char boundary[100]; TLS_VARS; @@ -156,8 +157,10 @@ #endif ) { php3_error(E_WARNING, "Unsupported content-type: %s", ctype); - return NULL; + unknown_content_type = 1; } + + /* if this is a POST file upload, figure out the boundary */ if (!strncasecmp(ctype, "multipart/form-data", 19)) { file_upload = 1; mb = strchr(ctype, '='); @@ -170,6 +173,8 @@ return NULL; } } + + /* read in all of the data */ length = GLOBAL(request_info).content_length; cnt = length; buf = (char *) emalloc((length + 1) * sizeof(char)); @@ -178,8 +183,8 @@ return NULL; } #if FHTTPD - memcpy(buf,req->databuffer,length); - buf[length]=0; + memcpy(buf,req->databuffer,length); + buf[length]=0; #else #if MODULE_MAGIC_NUMBER > 19961007 if (should_client_block(GLOBAL(php3_rqst))) { @@ -216,6 +221,8 @@ } while (bytes && cnt < length); #endif #endif + + /* if it was a POST file upload, pass it off to someone else */ if (file_upload) { php3_mime_split(buf, cnt, boundary, http_post_vars); efree(buf); @@ -233,6 +240,19 @@ _php3_hash_add(&GLOBAL(symbol_table), "HTTP_FDF_DATA", sizeof("HTTP_FDF_DATA"), postdata_ptr, sizeof(pval),NULL); } #endif + + if (unknown_content_type) { + pval rawdata; + rawdata.type = IS_STRING; + /* we don't need to copy buf, it was allocated with emalloc. + and we return NULL so nobody else will be trying to free it. + */ + rawdata.value.str.val = buf; + rawdata.value.str.len = cnt; + _php3_hash_add(&GLOBAL(symbol_table), "HTTP_RAW_POST_DATA", sizeof("HTTP_RAW_POST_DATA"), &rawdata, sizeof(pval), NULL); + return NULL; + } + return (buf); }

« previous php.dev (#7831) next »