summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorxXx-caillou-xXx2017-12-20 16:08:18 +0100
committerjvoisin2017-12-20 16:08:18 +0100
commita1675cd79b0df2478026573b0fac52464ef3c1b7 (patch)
treec40520065b0a7c4c9b9e8fb22250d5b8cbc30c39 /src
parentf7dfc937ebc7317fd3ff168e062d32119913d7ae (diff)
Make `setcookie` return true
We forgot to set a return value to the setcookie function, thus always returning false. Since very few frameworks/developers are checking the return value, it went unnoticed until we played with Magento, who effectively checks the return value.
Diffstat (limited to 'src')
-rw-r--r--src/sp_cookie_encryption.c1
-rw-r--r--src/tests/samesite_cookies.phpt16
2 files changed, 13 insertions, 4 deletions
diff --git a/src/sp_cookie_encryption.c b/src/sp_cookie_encryption.c
index 2d6c938..0e279ed 100644
--- a/src/sp_cookie_encryption.c
+++ b/src/sp_cookie_encryption.c
@@ -232,6 +232,7 @@ PHP_FUNCTION(sp_setcookie) {
232 call_user_function(CG(function_table), NULL, &func_name, &ret_val, 7, params); 232 call_user_function(CG(function_table), NULL, &func_name, &ret_val, 7, params);
233 233
234 func->handler = PHP_FN(sp_setcookie); 234 func->handler = PHP_FN(sp_setcookie);
235 RETURN_TRUE;
235} 236}
236 237
237int hook_cookies() { 238int hook_cookies() {
diff --git a/src/tests/samesite_cookies.phpt b/src/tests/samesite_cookies.phpt
index 12f3d72..fe74172 100644
--- a/src/tests/samesite_cookies.phpt
+++ b/src/tests/samesite_cookies.phpt
@@ -14,10 +14,18 @@ HTTPS=1
14EOF; 14EOF;
15--FILE-- 15--FILE--
16<?php 16<?php
17setcookie("super_cookie", "super_value"); 17if (!setcookie("super_cookie", "super_value")) {
18setcookie("awful_cookie", "awful_value"); 18 echo "setcookie failed.\n";
19setcookie("not_encrypted", "test_value", 1, "1", "1", false, true); 19}
20setcookie("nice_cookie", "nice_value", 1, "1", "1", true, true); 20if (!setcookie("awful_cookie", "awful_value")) {
21 echo "setcookie failed.\n";
22}
23if (!setcookie("not_encrypted", "test_value", 1, "1", "1", false, true)) {
24 echo "setcookie failed.\n";
25}
26if (!setcookie("nice_cookie", "nice_value", 1, "1", "1", true, true)) {
27 echo "setcookie failed.\n";
28}
21 29
22$expected = array( 30$expected = array(
23 'Set-Cookie: super_cookie=super_value; path=; samesite=Lax', 31 'Set-Cookie: super_cookie=super_value; path=; samesite=Lax',