diff options
Diffstat (limited to 'src/sp_crypt.c')
| -rw-r--r-- | src/sp_crypt.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/sp_crypt.c b/src/sp_crypt.c index b6eaa59..525da56 100644 --- a/src/sp_crypt.c +++ b/src/sp_crypt.c | |||
| @@ -91,6 +91,8 @@ int decrypt_zval(zval *pDest, bool simulation, zend_hash_key *hash_key) { | |||
| 91 | generate_key(key); | 91 | generate_key(key); |
| 92 | 92 | ||
| 93 | decrypted = ecalloc(ZSTR_LEN(debase64) + crypto_secretbox_ZEROBYTES, 1); | 93 | decrypted = ecalloc(ZSTR_LEN(debase64) + crypto_secretbox_ZEROBYTES, 1); |
| 94 | char *backup = ecalloc(ZSTR_LEN(debase64), 1); | ||
| 95 | memcpy(backup, ZSTR_VAL(debase64), ZSTR_LEN(debase64)); | ||
| 94 | 96 | ||
| 95 | ret = crypto_secretbox_open( | 97 | ret = crypto_secretbox_open( |
| 96 | decrypted, | 98 | decrypted, |
| @@ -105,19 +107,25 @@ int decrypt_zval(zval *pDest, bool simulation, zend_hash_key *hash_key) { | |||
| 105 | "Something went wrong with the decryption of %s. Using the cookie " | 107 | "Something went wrong with the decryption of %s. Using the cookie " |
| 106 | "'as it' instead of decrypting it", | 108 | "'as it' instead of decrypting it", |
| 107 | hash_key ? ZSTR_VAL(hash_key->key) : "the session"); | 109 | hash_key ? ZSTR_VAL(hash_key->key) : "the session"); |
| 110 | memcpy(ZSTR_VAL(debase64), backup, ZSTR_LEN(debase64)); | ||
| 111 | efree(backup); | ||
| 108 | return ZEND_HASH_APPLY_KEEP; | 112 | return ZEND_HASH_APPLY_KEEP; |
| 109 | } else { | 113 | } else { |
| 110 | sp_log_msg("cookie_encryption", SP_LOG_WARN, | 114 | sp_log_msg("cookie_encryption", SP_LOG_WARN, |
| 111 | "Something went wrong with the decryption of %s", | 115 | "Something went wrong with the decryption of %s", |
| 112 | hash_key ? ZSTR_VAL(hash_key->key) : "the session"); | 116 | hash_key ? ZSTR_VAL(hash_key->key) : "the session"); |
| 117 | efree(backup); | ||
| 113 | return ZEND_HASH_APPLY_REMOVE; | 118 | return ZEND_HASH_APPLY_REMOVE; |
| 114 | } | 119 | } |
| 115 | } | 120 | } |
| 121 | efree(backup); | ||
| 116 | 122 | ||
| 117 | ZVAL_STRINGL(pDest, (char *)(decrypted + crypto_secretbox_ZEROBYTES), | 123 | ZVAL_STRINGL(pDest, (char *)(decrypted + crypto_secretbox_ZEROBYTES), |
| 118 | ZSTR_LEN(debase64) - crypto_secretbox_NONCEBYTES - 1 - | 124 | ZSTR_LEN(debase64) - crypto_secretbox_NONCEBYTES - 1 - |
| 119 | crypto_secretbox_ZEROBYTES); | 125 | crypto_secretbox_ZEROBYTES); |
| 120 | 126 | ||
| 127 | zend_string_release(decrypted); | ||
| 128 | |||
| 121 | return ZEND_HASH_APPLY_KEEP; | 129 | return ZEND_HASH_APPLY_KEEP; |
| 122 | } | 130 | } |
| 123 | 131 | ||
