From 731175989c780c7ee0cb516b7fa4ffeb72999011 Mon Sep 17 00:00:00 2001
From: Adam Williamson <awilliam@redhat.com>
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
suggests this as the fix. He 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."
Signed-off-by: Adam Williamson <awilliam@redhat.com>
---
src/irc.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/irc.c b/src/irc.c
index 8163f32..98345aa 100644
--- a/src/irc.c
+++ b/src/irc.c
@@ -631,8 +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);
- ret[c - cur] = 0;
+ strncpy (ret, cur, c - cur + 1);
return ret;
}
if (index == num) {
@@ -640,8 +639,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);
- ret[c - cur] = 0;
+ strncpy (ret, cur, c - cur + 1);
return ret;
}
return NULL;
--
2.25.0