From: Jan Kneschke Date: Fri, 22 Nov 2002 13:39:06 +0000 (+0000) Subject: - fixed a buffer under run X-Git-Tag: RELEASE_1_0b2~69 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3598fbcef9bb96a4fbe3b77c1f0d5eace9475940;p=php - fixed a buffer under run - initializing variables is a good thing - in case of a invalid response we don't seg-fault here anymore --- diff --git a/ext/soap/php_http.c b/ext/soap/php_http.c index 38243dbb93..80b5e4047d 100644 --- a/ext/soap/php_http.c +++ b/ext/soap/php_http.c @@ -214,8 +214,7 @@ void get_http_soap_response(zval *this_ptr, char **buffer, int *buffer_len) efree(http_version); } - - + if(!get_http_body(stream, http_headers, &http_body, &http_body_size)) php_error(E_ERROR, "Error Fetching http body"); @@ -368,15 +367,16 @@ int get_http_body(SOAP_STREAM stream, char *headers, char **response, int *out_ done = FALSE; http_buf = emalloc(1); + *http_buf = '\0'; while(!done) { - cur = 0; - while(!(chunk_size[cur - 2] == '\r' && chunk_size[cur - 1] == '\n')) + for (cur = 0; cur < 3 || !(chunk_size[cur - 2] == '\r' && chunk_size[cur - 1] == '\n'); cur++) #ifdef PHP_STREAMS - chunk_size[cur++] = php_stream_getc(stream); + chunk_size[cur] = php_stream_getc(stream); #else - chunk_size[cur++] = php_sock_fgetc(stream); + chunk_size[cur] = php_sock_fgetc(stream); #endif + chunk_size[cur] = '\0'; if(sscanf(chunk_size,"%x",&buf_size) != -1) { http_buf = erealloc(http_buf,http_buf_size + buf_size);