gas strncpy warning

Message ID 20200226023551.GD5750@bubble.grove.modra.org
State New
Headers show
Series
  • gas strncpy warning
Related show

Commit Message

Alan Modra Feb. 26, 2020, 2:35 a.m.
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.


-- 
Alan Modra
Australia Development Lab, IBM

Patch

diff --git a/gas/read.c b/gas/read.c
index e603099e94..784d6a8f79 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)