Skip to content

Commit 706aefb

Browse files
committed
Fix bug #67730 - Null byte injection possible with imagexxx functions
1 parent 529da0f commit 706aefb

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ PHP NEWS
1616
- GD:
1717
. Fixed bug #66901 (php-gd 'c_color' NULL pointer dereference).
1818
(CVE-2014-2497) (Remi)
19+
. Fixed bug #67730 (Null byte injection possible with imagexxx functions).
20+
(CVE-2014-5120) (Ryan Mauger)
1921

2022
- Milter:
2123
. Fixed bug #67715 (php-milter does not build and crashes randomly). (Mike)

ext/gd/gd_ctx.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type,
124124
RETURN_FALSE;
125125
}
126126
} else if (Z_TYPE_P(to_zval) == IS_STRING) {
127+
if (CHECK_ZVAL_NULL_PATH(to_zval)) {
128+
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid 2nd parameter, filename must not contain null bytes");
129+
RETURN_FALSE;
130+
}
131+
127132
stream = php_stream_open_wrapper(Z_STRVAL_P(to_zval), "wb", REPORT_ERRORS|IGNORE_PATH|IGNORE_URL_WIN, NULL);
128133
if (stream == NULL) {
129134
RETURN_FALSE;

0 commit comments

Comments
 (0)