Avoid memmove() call when buffers are already the same. (#935)
This completes the work started in commit
fbe3eb265f
This commit is contained in:
parent
83bfae5bdb
commit
f1652acba2
@ -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