gas strncpy warning
authorAlan Modra <amodra@gmail.com>
Wed, 26 Feb 2020 02:08:11 +0000 (12:38 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 26 Feb 2020 02:34:48 +0000 (13:04 +1030)
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.

gas/ChangeLog
gas/read.c

index d00fb87653607c64f7238e4ec93adc70d78f67c0..001af54cb5f26bb331d5e02c7d1ca8a76d936f02 100644 (file)
@@ -1,3 +1,8 @@
+2020-02-26  Alan Modra  <amodra@gmail.com>
+
+       * read.c (read_a_source_file): Call strncpy with length one
+       less than size of original_case_string.
+
 2020-02-26  Alan Modra  <amodra@gmail.com>
 
        * config/obj-elf.c: Indent labels correctly.
index e603099e940fcdf712fe8d6b357b5c4d4680c4ab..784d6a8f79e6a99f9ea17ebe82d62401eb00d22f 100644 (file)
@@ -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)