d2399a
From 1daa4c0090b7cd8178dcaa96287234c69ac6ca18 Mon Sep 17 00:00:00 2001
d2399a
From: Stanislav Malyshev <stas@php.net>
d2399a
Date: Mon, 18 Aug 2014 22:49:10 -0700
d2399a
Subject: [PATCH] Fix bug #67730 - Null byte injection possible with imagexxx
d2399a
 functions
d2399a
d2399a
---
d2399a
 ext/gd/gd_ctx.c | 5 +++++
d2399a
 1 file changed, 5 insertions(+)
d2399a
d2399a
diff --git a/ext/gd/gd_ctx.c b/ext/gd/gd_ctx.c
d2399a
index 59eff80..253b664 100644
d2399a
--- a/ext/gd/gd_ctx.c
d2399a
+++ b/ext/gd/gd_ctx.c
d2399a
@@ -124,6 +124,11 @@ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type,
d2399a
 				RETURN_FALSE;
d2399a
 			}
d2399a
 		} else if (Z_TYPE_P(to_zval) == IS_STRING) {
d2399a
+			if (CHECK_ZVAL_NULL_PATH(to_zval)) {
d2399a
+				php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid 2nd parameter, filename must not contain null bytes");
d2399a
+				RETURN_FALSE;
d2399a
+			}
d2399a
+
d2399a
 			stream = php_stream_open_wrapper(Z_STRVAL_P(to_zval), "wb", REPORT_ERRORS|IGNORE_PATH|IGNORE_URL_WIN, NULL);
d2399a
 			if (stream == NULL) {
d2399a
 				RETURN_FALSE;
d2399a
-- 
d2399a
1.9.2
d2399a