1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-23 20:15:19 -07:00

secretbox: avoid a useless memmove() if the source and destination addresses are the same

This commit is contained in:
Frank Denis 2017-06-14 15:57:06 +02:00
parent 3a9c4c38f7
commit fbe3eb265f
2 changed files with 4 additions and 4 deletions

View File

@ -26,9 +26,9 @@ crypto_secretbox_detached(unsigned char *c, unsigned char *mac,
crypto_core_hsalsa20(subkey, n, k, NULL);
if (((uintptr_t) c >= (uintptr_t) m &&
if (((uintptr_t) c > (uintptr_t) m &&
(uintptr_t) c - (uintptr_t) m < mlen) ||
((uintptr_t) m >= (uintptr_t) c &&
((uintptr_t) m > (uintptr_t) c &&
(uintptr_t) m - (uintptr_t) c < mlen)) {
memmove(c, m, mlen);
m = c;

View File

@ -30,9 +30,9 @@ crypto_secretbox_xchacha20poly1305_detached(unsigned char *c,
crypto_core_hchacha20(subkey, n, k, NULL);
if (((uintptr_t) c >= (uintptr_t) m &&
if (((uintptr_t) c > (uintptr_t) m &&
(uintptr_t) c - (uintptr_t) m < mlen) ||
((uintptr_t) m >= (uintptr_t) c &&
((uintptr_t) m > (uintptr_t) c &&
(uintptr_t) m - (uintptr_t) c < mlen)) {
memmove(c, m, mlen);
m = c;