fix UBSanitizer issue: memcpy/memcmp require non-null pointers even when the length is zero

This commit is contained in:
Karel Miko 2026-05-03 17:39:58 +02:00
parent 76a9ece653
commit 5c8ac18bd1
2 changed files with 3 additions and 1 deletions

View file

@ -161,7 +161,7 @@ static LTC_INLINE int s_siv_S2V_T(siv_omac_ctx_t *ctx,
} else {
s_siv_dbl(D);
XMEMSET(&T, 0, sizeof(T));
XMEMCPY(&T, in, inlen);
if (inlen != 0) XMEMCPY(&T, in, inlen);
T.u.byte[inlen] = 0x80;
s_siv_xor_buf(D, &T);

View file

@ -59,6 +59,8 @@ int ltc_compare_testvector(const void* is, const unsigned long is_len, const voi
int res = 0;
if(is_len != should_len) {
res = is_len > should_len ? -1 : 1;
} else if (is_len == 0) {
res = 0;
} else {
res = XMEMCMP(is, should, is_len);
}