mirror of
https://github.com/jedisct1/libsodium.git
synced 2024-12-19 18:15:18 -07:00
Avoid memmove() call when buffers are already the same. (#935)
This completes the work started in commit
fbe3eb265f
This commit is contained in:
parent
a0a8706c9d
commit
4bbc34c09c
@ -101,9 +101,9 @@ crypto_secretbox_open_detached(unsigned char *m, const unsigned char *c,
|
||||
if (m == NULL) {
|
||||
return 0;
|
||||
}
|
||||
if (((uintptr_t) c >= (uintptr_t) m &&
|
||||
if (((uintptr_t) c > (uintptr_t) m &&
|
||||
(uintptr_t) c - (uintptr_t) m < clen) ||
|
||||
((uintptr_t) m >= (uintptr_t) c &&
|
||||
((uintptr_t) m > (uintptr_t) c &&
|
||||
(uintptr_t) m - (uintptr_t) c < clen)) { /* LCOV_EXCL_LINE */
|
||||
memmove(m, c, clen);
|
||||
c = m;
|
||||
|
@ -108,9 +108,9 @@ crypto_secretbox_xchacha20poly1305_open_detached(unsigned char *m,
|
||||
if (m == NULL) {
|
||||
return 0;
|
||||
}
|
||||
if (((uintptr_t) c >= (uintptr_t) m &&
|
||||
if (((uintptr_t) c > (uintptr_t) m &&
|
||||
(uintptr_t) c - (uintptr_t) m < clen) ||
|
||||
((uintptr_t) m >= (uintptr_t) c &&
|
||||
((uintptr_t) m > (uintptr_t) c &&
|
||||
(uintptr_t) m - (uintptr_t) c < clen)) { /* LCOV_EXCL_LINE */
|
||||
memmove(m, c, clen);
|
||||
c = m;
|
||||
|
Loading…
Reference in New Issue
Block a user