libmemif: fix insecure uses of strncpy 24/31024/9
authorAndrew Yourtchenko <ayourtch@gmail.com>
Fri, 29 Jan 2021 14:18:12 +0000 (14:18 +0000)
committerDamjan Marion <dmarion@me.com>
Mon, 8 Feb 2021 10:27:06 +0000 (10:27 +0000)
commite5b7ca4bcea8c404d95e00f5db4c40d47b6e185b
tree8c63d909d628477c745e0a3455fb5e5ae45e6a48
parent1421748e3cd98d7355b1a1db283803a571569927
libmemif: fix insecure uses of strncpy

A calling patterm of "strncpy(dst, src, strlen(src))" invites a lot of troubles.

However, even using the target size may result in a problem if the string is
longer, since then the termination is not done.

Use strlcpy(dst, src, sizeof(dst)), which will always null-terminate
the string.

Change-Id: I8ddaf3dc8380a78af08914e81849279dae7ab24a
Type: fix
Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
extras/libmemif/src/CMakeLists.txt
extras/libmemif/src/main.c
extras/libmemif/src/memif_private.h
extras/libmemif/src/socket.c