We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents bd5f52f + 7ae93a2 commit 8ac56c1Copy full SHA for 8ac56c1
ext/standard/string.c
@@ -266,6 +266,11 @@ PHP_FUNCTION(hex2bin)
266
return;
267
}
268
269
+ if (datalen % 2 != 0) {
270
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Hexadecimal input string must have an even length");
271
+ RETURN_FALSE;
272
+ }
273
+
274
result = php_hex2bin((unsigned char *)data, datalen, &newlen);
275
276
if (!result) {
ext/standard/tests/strings/bug61660.phpt
@@ -0,0 +1,11 @@
1
+--TEST--
2
+Bug #61660: bin2hex(hex2bin($data)) != $data
3
+--FILE--
4
+<?php
5
6
+var_dump(hex2bin('123'));
7
8
+?>
9
+--EXPECTF--
10
+Warning: hex2bin(): Hexadecimal input string must have an even length in %s on line %d
11
+bool(false)
0 commit comments