lib/strutils: make sure mem2strcpy() buffer is zeroized

Let's make the function robust for work with strings and uninitialized
buffers.

Reported-by: Sean Anderson <seanga2@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
pull/1573/head
Karel Zak 9 months ago
parent 38e93216e8
commit 9c05f4b6bf
  1. 2
      include/strutils.h

@ -106,8 +106,8 @@ static inline char *mem2strcpy(char *dest, const void *src, size_t n, size_t nma
if (n + 1 > nmax)
n = nmax - 1;
memset(dest, '\0', nmax);
memcpy(dest, src, n);
dest[nmax-1] = '\0';
return dest;
}

Loading…
Cancel
Save