diff options
author | Demi Marie Obenour <demi@invisiblethingslab.com> | 2022-01-27 11:48:34 -0500 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2022-03-31 12:23:08 +0300 |
commit | 6d3ce1c96833e896f082df81c727687da130f416 (patch) | |
tree | a0282f693b2feaca4a677a4f62bd1a632f5881e4 | |
parent | 3a6b1d8fbf846d3f1b139d343fdfddebe99ae42b (diff) | |
download | rpm-6d3ce1c96833e896f082df81c727687da130f416.tar.gz |
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.
-rw-r--r-- | lib/rpmfi.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/rpmfi.c b/lib/rpmfi.c index 24872658d..f27cb0ff7 100644 --- a/lib/rpmfi.c +++ b/lib/rpmfi.c @@ -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++) { - memcpy(t, arr[i], lengths[i]); - free(arr[i]); + if (arr[i]) { + memcpy(t, arr[i], lengths[i]); + free(arr[i]); + } t += maxlen; } *len = maxlen; |