]> granicus.if.org Git - php/commitdiff
Fix bug #67730 - Null byte injection possible with imagexxx functions
authorStanislav Malyshev <stas@php.net>
Tue, 19 Aug 2014 05:49:10 +0000 (22:49 -0700)
committerStanislav Malyshev <stas@php.net>
Tue, 19 Aug 2014 05:49:10 +0000 (22:49 -0700)
NEWS
ext/gd/gd_ctx.c

diff --git a/NEWS b/NEWS
index cd34e9e54eb214d7e9c20e9a4bb137f0c06fcef1..a3a5268c0785261803c506e2d68c8159c742761e 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,8 @@ PHP                                                                        NEWS
 - GD:
   . Fixed bug #66901 (php-gd 'c_color' NULL pointer dereference).
     (CVE-2014-2497) (Remi)
+  . Fixed bug #67730 (Null byte injection possible with imagexxx functions).
+    (CVE-2014-5120) (Ryan Mauger)
 
 - Milter:
   . Fixed bug #67715 (php-milter does not build and crashes randomly). (Mike)
index bff691fad2f0c5782793318354740ab2e12f56a2..eafbab5896185560fec80dde0851bb9f35dab827 100644 (file)
@@ -124,6 +124,11 @@ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type,
                                RETURN_FALSE;
                        }
                } else if (Z_TYPE_P(to_zval) == IS_STRING) {
+                       if (CHECK_ZVAL_NULL_PATH(to_zval)) {
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid 2nd parameter, filename must not contain null bytes");
+                               RETURN_FALSE;
+                       }
+
                        stream = php_stream_open_wrapper(Z_STRVAL_P(to_zval), "wb", REPORT_ERRORS|IGNORE_PATH|IGNORE_URL_WIN, NULL);
                        if (stream == NULL) {
                                RETURN_FALSE;