public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* gas strncpy warning
@ 2020-02-26  2:35 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2020-02-26  2:35 UTC (permalink / raw)
  To: binutils

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/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)

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-02-26  2:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-26  2:35 gas strncpy warning Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).