From: Alan Modra Date: Wed, 26 Feb 2020 02:08:11 +0000 (+1030) Subject: gas strncpy warning X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=42135cadf5a3097df340eb85e96c0109a9842907;p=binutils-gdb.git gas strncpy warning Avoid a warning that the buffer may not be zero terminated. * read.c (read_a_source_file): Call strncpy with length one less than size of original_case_string. --- diff --git a/gas/ChangeLog b/gas/ChangeLog index d00fb876536..001af54cb5f 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,8 @@ +2020-02-26 Alan Modra + + * read.c (read_a_source_file): Call strncpy with length one + less than size of original_case_string. + 2020-02-26 Alan Modra * config/obj-elf.c: Indent labels correctly. diff --git a/gas/read.c b/gas/read.c index e603099e940..784d6a8f79e 100644 --- a/gas/read.c +++ b/gas/read.c @@ -1052,7 +1052,8 @@ read_a_source_file (const char *name) { char *s2 = s; - strncpy (original_case_string, s2, sizeof (original_case_string)); + strncpy (original_case_string, s2, + sizeof (original_case_string) - 1); original_case_string[sizeof (original_case_string) - 1] = 0; while (*s2)