Skip to content

Commit ac125d4

Browse files
committed
uri: Fix RFC3986 to_string implementation with ExcludeFragment returning non-terminated strings
zend_string_truncate() doesn't put a NUL byte. Right now this doesn't matter as this code path is only hittable via the equals() method, but if other extension (or future other code) starts using this code path, then it can be problematic as all user-exposed zend_strings need to end with a NUL byte.
1 parent daf4d54 commit ac125d4

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

ext/uri/uri_parser_rfc3986.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,7 @@ ZEND_ATTRIBUTE_NONNULL static zend_string *php_uri_parser_rfc3986_to_string(void
595595
const char *pos = zend_memrchr(ZSTR_VAL(uri_string), '#', ZSTR_LEN(uri_string));
596596
if (pos != NULL) {
597597
uri_string = zend_string_truncate(uri_string, (pos - ZSTR_VAL(uri_string)), false);
598+
ZSTR_VAL(uri_string)[ZSTR_LEN(uri_string)] = '\0';
598599
}
599600
}
600601

0 commit comments

Comments
 (0)