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:
parent
3a9c4c38f7
commit
fbe3eb265f
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user