php7: fix issue 5488
authorPhilip Prindeville <philipp@redfish-solutions.com>
Thu, 25 Jan 2018 18:38:57 +0000 (11:38 -0700)
committerPhilip Prindeville <philipp@redfish-solutions.com>
Thu, 25 Jan 2018 19:51:51 +0000 (12:51 -0700)
Depending on which version of libiconv you're using, php_iconv_string()
doesn't always null out *out as part of its initialization.  This
patch makes that behavior invariant.

Submitted upstream as https://github.com/php/php-src/pull/3037 where
it's approved and waiting a merge.

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
lang/php7/Makefile
lang/php7/patches/1012-php_iconv_string-null-out-pointer [new file with mode: 0644]

index 48d98891fc5ab8d6d0e8f2a0f51aab3fdac776d6..f1f781fe41ee83e7f91432c1c25380be7cccea28 100644 (file)
@@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=php
 PKG_VERSION:=7.2.1
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_MAINTAINER:=Michael Heimpold <mhei@heimpold.de>
 
diff --git a/lang/php7/patches/1012-php_iconv_string-null-out-pointer b/lang/php7/patches/1012-php_iconv_string-null-out-pointer
new file mode 100644 (file)
index 0000000..5f71b7d
--- /dev/null
@@ -0,0 +1,42 @@
+commit 8b6882d95dfe9096a22052bbff0c134b10932d20
+Author: Philip Prindeville <philipp@redfish-solutions.com>
+Date:   Wed Jan 24 18:47:19 2018 -0700
+
+    Be consistent in clearing out in php_iconv_string()
+    
+    Also, don't bother checking returned point in error case since it
+    will always be NULL (and not require free()ing, obviously).
+
+diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c
+index 35dafd4..bc7f3aa 100644
+--- a/ext/iconv/iconv.c
++++ b/ext/iconv/iconv.c
+@@ -559,6 +559,8 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len,
+       size_t result;
+       zend_string *ret, *out_buffer;
++      *out = NULL;
++
+       /*
+         This is not the right way to get output size...
+         This is not space efficient for large text.
+@@ -984,9 +986,6 @@ static php_iconv_err_t _php_iconv_strpos(size_t *pretval,
+       err = php_iconv_string(ndl, ndl_nbytes, &ndl_buf, GENERIC_SUPERSET_NAME, enc);
+       if (err != PHP_ICONV_ERR_SUCCESS) {
+-              if (ndl_buf != NULL) {
+-                      zend_string_free(ndl_buf);
+-              }
+               return err;
+       }
+@@ -2463,9 +2462,6 @@ PHP_NAMED_FUNCTION(php_if_iconv)
+       if (err == PHP_ICONV_ERR_SUCCESS && out_buffer != NULL) {
+               RETVAL_STR(out_buffer);
+       } else {
+-              if (out_buffer != NULL) {
+-                      zend_string_free(out_buffer);
+-              }
+               RETURN_FALSE;
+       }
+ }