Skip to content

Commit d5b6608

Browse files
author
Brian France
committed
Added checks for invalid characters in a cookie name or cookie data from setrawcookie
1 parent e6ae5c3 commit d5b6608

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

ext/standard/head.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,16 @@ PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len, t
7474
sapi_header_line ctr = {0};
7575
int result;
7676

77+
if (name && strpbrk(name, "=,; \t\r\n\013\014") != NULL) { /* man isspace for \013 and \014 */
78+
zend_error( E_WARNING, "Cookie names can not contain any of the folllowing '=,; \\t\\r\\n\\013\\014' (%s)", name );
79+
return FAILURE;
80+
}
81+
82+
if (!url_encode && value && strpbrk(value, ",; \t\r\n\013\014") != NULL) { /* man isspace for \013 and \014 */
83+
zend_error( E_WARNING, "Cookie values can not contain any of the folllowing ',; \\t\\r\\n\\013\\014' (%s)", value );
84+
return FAILURE;
85+
}
86+
7787
len += name_len;
7888
if (value && url_encode) {
7989
int encoded_value_len;

0 commit comments

Comments
 (0)