Avoid calling memcpy() on NULL

base2bin() would call memcpy() on NULL for empty fsverity signatures.
This is undefined behavior, even if the length is 0.
This commit is contained in:
Demi Marie Obenour 2022-01-27 11:48:34 -05:00 committed by Panu Matilainen
parent 3a6b1d8fbf
commit 6d3ce1c968
1 changed files with 4 additions and 2 deletions

View File

@ -1613,8 +1613,10 @@ static uint8_t *base2bin(Header h, rpmTagVal tag, rpm_count_t num, int *len)
t = bin = xcalloc(num, maxlen);
for (i = 0; i < num; i++) {
if (arr[i]) {
memcpy(t, arr[i], lengths[i]);
free(arr[i]);
}
t += maxlen;
}
*len = maxlen;