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