diff options
| author | xXx-caillou-xXx | 2017-12-20 16:08:18 +0100 |
|---|---|---|
| committer | jvoisin | 2017-12-20 16:08:18 +0100 |
| commit | a1675cd79b0df2478026573b0fac52464ef3c1b7 (patch) | |
| tree | c40520065b0a7c4c9b9e8fb22250d5b8cbc30c39 /src | |
| parent | f7dfc937ebc7317fd3ff168e062d32119913d7ae (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.c | 1 | ||||
| -rw-r--r-- | src/tests/samesite_cookies.phpt | 16 |
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 | ||
| 237 | int hook_cookies() { | 238 | int 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 | |||
| 14 | EOF; | 14 | EOF; |
| 15 | --FILE-- | 15 | --FILE-- |
| 16 | <?php | 16 | <?php |
| 17 | setcookie("super_cookie", "super_value"); | 17 | if (!setcookie("super_cookie", "super_value")) { |
| 18 | setcookie("awful_cookie", "awful_value"); | 18 | echo "setcookie failed.\n"; |
| 19 | setcookie("not_encrypted", "test_value", 1, "1", "1", false, true); | 19 | } |
| 20 | setcookie("nice_cookie", "nice_value", 1, "1", "1", true, true); | 20 | if (!setcookie("awful_cookie", "awful_value")) { |
| 21 | echo "setcookie failed.\n"; | ||
| 22 | } | ||
| 23 | if (!setcookie("not_encrypted", "test_value", 1, "1", "1", false, true)) { | ||
| 24 | echo "setcookie failed.\n"; | ||
| 25 | } | ||
| 26 | if (!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', |
