com php-src: prohibit empty cookie names for setcookie(): ext/standard/head.c ext/standard/tests/network/bug69523.phpt

From: Date: Tue, 12 May 2015 08:47:35 +0000
Subject: com php-src: prohibit empty cookie names for setcookie(): ext/standard/head.c ext/standard/tests/network/bug69523.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-86673@lists.php.net to get a copy of this message
Commit: 613f7475793159124379371fe78e99c3c9d633f0 Author: Christoph M. Becker <cmbecker69@gmx.de> Sat, 2 May 2015 00:10:28 +0200 Committer: Julien Pauli <jpauli@php.net> Tue, 12 May 2015 10:47:35 +0200 Parents: 1b9a88ed1cd42893a7495b8a2259916df7c44a0a Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=613f7475793159124379371fe78e99c3c9d633f0 Log: prohibit empty cookie names for setcookie() Changed paths: M ext/standard/head.c A ext/standard/tests/network/bug69523.phpt Diff: diff --git a/ext/standard/head.c b/ext/standard/head.c index bdb3e59..22a2af1 100644 --- a/ext/standard/head.c +++ b/ext/standard/head.c @@ -86,7 +86,10 @@ PHPAPI int php_setcookie(char *name, size_t name_len, char *value, size_t value_ int result; zend_string *encoded_value = NULL; - if (name && strpbrk(name, "=,; \t\r\n\013\014") != NULL) { /* man isspace for \013 and \014 */ + if (!name_len) { + zend_error( E_WARNING, "Cookie names must not be empty" ); + return FAILURE; + } else if (name && strpbrk(name, "=,; \t\r\n\013\014") != NULL) { /* man isspace for \013 and \014 */ zend_error( E_WARNING, "Cookie names cannot contain any of the following '=,; \\t\\r\\n\\013\\014'" ); return FAILURE; } diff --git a/ext/standard/tests/network/bug69523.phpt b/ext/standard/tests/network/bug69523.phpt new file mode 100644 index 0000000..979ae00 --- /dev/null +++ b/ext/standard/tests/network/bug69523.phpt @@ -0,0 +1,8 @@ +--TEST-- +setcookie() allows empty cookie name +--FILE-- +<?php +setcookie('', 'foo'); +?> +--EXPECTF-- +Warning: Cookie names must not be empty in %s on line %d

« previous php.cvs (#86673) next »