summaryrefslogtreecommitdiff
path: root/src/sp_cookie_encryption.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sp_cookie_encryption.c')
-rw-r--r--src/sp_cookie_encryption.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/src/sp_cookie_encryption.c b/src/sp_cookie_encryption.c
index c749040..04c864f 100644
--- a/src/sp_cookie_encryption.c
+++ b/src/sp_cookie_encryption.c
@@ -63,9 +63,17 @@ int decrypt_cookie(zval *pDest, int num_args, va_list args,
63 63
64 if (ZSTR_LEN(debase64) < 64 if (ZSTR_LEN(debase64) <
65 crypto_secretbox_NONCEBYTES + crypto_secretbox_ZEROBYTES) { 65 crypto_secretbox_NONCEBYTES + crypto_secretbox_ZEROBYTES) {
66 sp_log_msg("cookie_encryption", SP_LOG_DROP, 66 if (true == cookie->simulation) {
67 "Buffer underflow tentative detected in cookie encryption handling."); 67 sp_log_msg("cookie_encryption", SP_LOG_SIMULATION,
68 return ZEND_HASH_APPLY_REMOVE; 68 "Buffer underflow tentative detected in cookie encryption handling "
69 "for %s. Using the cookie 'as it' instead of decrypting it.",
70 ZSTR_VAL(hash_key->key));
71 return ZEND_HASH_APPLY_KEEP;
72 } else {
73 sp_log_msg("cookie_encryption", SP_LOG_DROP,
74 "Buffer underflow tentative detected in cookie encryption handling.");
75 return ZEND_HASH_APPLY_REMOVE;
76 }
69 } 77 }
70 78
71 generate_key(key); 79 generate_key(key);
@@ -78,11 +86,18 @@ int decrypt_cookie(zval *pDest, int num_args, va_list args,
78 ZSTR_LEN(debase64) - crypto_secretbox_NONCEBYTES, 86 ZSTR_LEN(debase64) - crypto_secretbox_NONCEBYTES,
79 (unsigned char *)ZSTR_VAL(debase64), key); 87 (unsigned char *)ZSTR_VAL(debase64), key);
80 88
81 if (ret == -1) { 89 if (-1 == ret) {
82 sp_log_msg("cookie_encryption", SP_LOG_DROP, 90 if (true == cookie->simulation) {
83 "Something went wrong with the decryption of %s.", 91 sp_log_msg("cookie_encryption", SP_LOG_SIMULATION,
84 ZSTR_VAL(hash_key->key)); 92 "Something went wrong with the decryption of %s. Using the cookie "
85 return ZEND_HASH_APPLY_REMOVE; 93 "'as it' instead of decrypting it", ZSTR_VAL(hash_key->key));
94 return ZEND_HASH_APPLY_KEEP;
95 } else {
96 sp_log_msg("cookie_encryption", SP_LOG_DROP,
97 "Something went wrong with the decryption of %s.",
98 ZSTR_VAL(hash_key->key));
99 return ZEND_HASH_APPLY_REMOVE;
100 }
86 } 101 }
87 102
88 ZVAL_STRINGL(pDest, (char *)(decrypted + crypto_secretbox_ZEROBYTES), 103 ZVAL_STRINGL(pDest, (char *)(decrypted + crypto_secretbox_ZEROBYTES),