From 92819d87eae8ec8076d67a647adbd81d3c29e8b8 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Fri, 7 Feb 2020 11:20:45 -0800 Subject: [PATCH] Fix stringop-truncation error (thanks DJ Delorie) See https://bugzilla.redhat.com/show_bug.cgi?id=1799189. bip build fails on current Fedora Rawhide GCC and glibc. DJ Delorie says "The warning is correct; the code is copying up to the NUL on purpose, then copying the NUL in a separate command. Not sure why." Tom Hughes suggests this as the fix. --- src/irc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/irc.c b/src/irc.c index 8163f32..c048329 100644 --- a/src/irc.c +++ b/src/irc.c @@ -631,7 +631,7 @@ static char *get_str_elem(char *str, int num) if (c - cur < 1) return NULL; ret = bip_malloc(c - cur + 1); - strncpy(ret, cur, c - cur); + memcpy(ret, cur, c - cur); ret[c - cur] = 0; return ret; } @@ -640,7 +640,7 @@ static char *get_str_elem(char *str, int num) if (c - cur < 1) return NULL; ret = bip_malloc(c - cur + 1); - strncpy(ret, cur, c - cur); + memcpy(ret, cur, c - cur); ret[c - cur] = 0; return ret; }