com php-src: Fixed base64decode usage: main/streams/memory.c

From: Date: Tue, 04 Mar 2014 12:08:06 +0000
Subject: com php-src: Fixed base64decode usage: main/streams/memory.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-77800@lists.php.net to get a copy of this message
Commit: 4358e4b7cdea807ef1528b7223cb42f11feae200 Author: Xinchen Hui <laruence@gmail.com> Tue, 4 Mar 2014 20:08:06 +0800 Parents: bab58ab97e34f1afa26f1a0e46b619cc72695c97 Branches: phpng Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=4358e4b7cdea807ef1528b7223cb42f11feae200 Log: Fixed base64decode usage Changed paths: M main/streams/memory.c Diff: diff --git a/main/streams/memory.c b/main/streams/memory.c index b13d8b6..e11a109 100644 --- a/main/streams/memory.c +++ b/main/streams/memory.c @@ -20,9 +20,9 @@ #define _GNU_SOURCE #include "php.h" +#include "ext/standard/base64.h" PHPAPI int php_url_decode(char *str, int len); -PHPAPI unsigned char *php_base64_decode(const unsigned char *str, int length, int *ret_length); /* Memory streams use a dynamic memory buffer to emulate a stream. * You can use php_stream_memory_open to create a readonly stream @@ -607,6 +607,7 @@ static php_stream * php_stream_url_wrap_rfc2397(php_stream_wrapper *wrapper, con off_t newoffs; zval meta; int base64 = 0, ilen; + zend_string *base64_comma = NULL; ZVAL_NULL(&meta); if (memcmp(path, "data:", 5)) { @@ -674,7 +675,7 @@ static php_stream * php_stream_url_wrap_rfc2397(php_stream_wrapper *wrapper, con plen = sep - path; vlen = (semi ? semi - sep : mlen - plen) - 1 /* '=' */; key = estrndup(path, plen); - add_assoc_stringl_ex(&meta, key, plen + 1, sep + 1, vlen, 1); + add_assoc_stringl_ex(&meta, key, plen, sep + 1, vlen, 1); efree(key); plen += vlen + 1; mlen -= plen; @@ -695,12 +696,14 @@ static php_stream * php_stream_url_wrap_rfc2397(php_stream_wrapper *wrapper, con dlen--; if (base64) { - comma = (char*)php_base64_decode((const unsigned char *)comma, dlen, &ilen); - if (!comma) { + base64_comma = php_base64_decode((const unsigned char *)comma, dlen); + if (!base64_comma) { zval_ptr_dtor(&meta); php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "rfc2397: unable to decode"); return NULL; } + comma = base64_comma->val; + ilen = base64_comma->len; } else { comma = estrndup(comma, dlen); ilen = dlen = php_url_decode(comma, dlen); @@ -723,7 +726,11 @@ static php_stream * php_stream_url_wrap_rfc2397(php_stream_wrapper *wrapper, con ts->mode = mode && mode[0] == 'r' && mode[1] != '+' ? TEMP_STREAM_READONLY : 0; ZVAL_COPY_VALUE(&ts->meta, &meta); } - efree(comma); + if (base64_comma) { + STR_FREE(base64_comma); + } else { + efree(comma); + } return stream; }

« previous php.cvs (#77800) next »