X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=lib%2Fcontent_encoding.c;h=fa36aca4cab486d15f4654d3c58d7d7ff9c21f47;hb=88d478478059f53e6de0d1267c3a1e6b02c4273f;hp=c3996a1130d3a4eb6af52d492f513d393cd4dc46;hpb=e9bdad71c8277e20607fa1eaf0027d53a0dc1f37;p=platform%2Fupstream%2Fcurl.git diff --git a/lib/content_encoding.c b/lib/content_encoding.c index c3996a1..fa36aca 100644 --- a/lib/content_encoding.c +++ b/lib/content_encoding.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2016, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2011, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -28,8 +28,8 @@ #include #include "sendf.h" #include "content_encoding.h" -#include "strdup.h" #include "curl_memory.h" + #include "memdebug.h" /* Comment this out if zlib is always going to be at least ver. 1.2.0.4 @@ -69,11 +69,11 @@ process_zlib_error(struct connectdata *conn, z_stream *z) { struct Curl_easy *data = conn->data; if(z->msg) - failf(data, "Error while processing content unencoding: %s", - z->msg); + failf (data, "Error while processing content unencoding: %s", + z->msg); else - failf(data, "Error while processing content unencoding: " - "Unknown failure within decompression software."); + failf (data, "Error while processing content unencoding: " + "Unknown failure within decompression software."); return CURLE_BAD_CONTENT_ENCODING; } @@ -314,7 +314,7 @@ Curl_unencode_gzip_write(struct connectdata *conn, #ifndef OLD_ZLIB_SUPPORT /* Support for old zlib versions is compiled away and we are running with an old version, so return an error. */ - return exit_zlib(z, &k->zlib_init, CURLE_WRITE_ERROR); + return exit_zlib(z, &k->zlib_init, CURLE_FUNCTION_NOT_FOUND); #else /* This next mess is to get around the potential case where there isn't @@ -327,14 +327,14 @@ Curl_unencode_gzip_write(struct connectdata *conn, * can handle the gzip header themselves. */ - switch(k->zlib_init) { + switch (k->zlib_init) { /* Skip over gzip header? */ case ZLIB_INIT: { /* Initial call state */ ssize_t hlen; - switch(check_gzip_header((unsigned char *)k->str, nread, &hlen)) { + switch (check_gzip_header((unsigned char *)k->str, nread, &hlen)) { case GZIP_OK: z->next_in = (Bytef *)k->str + hlen; z->avail_in = (uInt)(nread - hlen); @@ -371,15 +371,18 @@ Curl_unencode_gzip_write(struct connectdata *conn, { /* Need more gzip header data state */ ssize_t hlen; + unsigned char *oldblock = z->next_in; + z->avail_in += (uInt)nread; - z->next_in = Curl_saferealloc(z->next_in, z->avail_in); + z->next_in = realloc(z->next_in, z->avail_in); if(z->next_in == NULL) { + free(oldblock); return exit_zlib(z, &k->zlib_init, CURLE_OUT_OF_MEMORY); } /* Append the new block of data to the previous one */ memcpy(z->next_in + z->avail_in - nread, k->str, nread); - switch(check_gzip_header(z->next_in, z->avail_in, &hlen)) { + switch (check_gzip_header(z->next_in, z->avail_in, &hlen)) { case GZIP_OK: /* This is the zlib stream data */ free(z->next_in);