[Spice-devel] [PATCH spice] reds: Replace strncpy with g_strlcpy
Pavel Grunt
pgrunt at redhat.com
Fri Nov 18 12:25:24 UTC 2016
strncpy is considered unsafe
---
cfg.mk | 1 -
server/reds.c | 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index 66235ee..3e5d345 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -42,7 +42,6 @@ local-checks-to-skip = \
sc_prohibit_stat_st_blocks \
sc_prohibit_magic_number_exit \
sc_prohibit_strcmp \
- sc_prohibit_strncpy \
sc_prohibit_undesirable_word_seq \
sc_root_tests \
sc_space_tab \
diff --git a/server/reds.c b/server/reds.c
index 92feea1..0e68973 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -2504,7 +2504,7 @@ static int reds_init_socket(const char *addr, int portnr, int family)
}
local.sun_family = AF_UNIX;
- strncpy(local.sun_path, addr, sizeof(local.sun_path) -1);
+ g_strlcpy(local.sun_path, addr, sizeof(local.sun_path));
unlink(local.sun_path);
len = SUN_LEN(&local);
if (bind(slisten, (struct sockaddr *)&local, len) == -1) {
--
2.10.2
More information about the Spice-devel
mailing list