public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* nds32: __builtin_strncpy bound equals destination size
@ 2021-05-27  1:27 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2021-05-27  1:27 UTC (permalink / raw)
  To: binutils

	* config/tc-nds32.c (do_pseudo_push_bhwd, do_pseudo_pop_bhwd),
	(do_pseudo_pusha, do_pseudo_pushi): Avoid fortify strncpy bound
	error.

diff --git a/gas/config/tc-nds32.c b/gas/config/tc-nds32.c
index e5c0eaf0866..c5bad6b476a 100644
--- a/gas/config/tc-nds32.c
+++ b/gas/config/tc-nds32.c
@@ -3255,8 +3255,8 @@ do_pseudo_push_bhwd (int argc ATTRIBUTE_UNUSED, char *argv[],
 
   if (argc == 2)
     {
-      strncpy (location, argv[1], 8);
-      location[7] = '\0';
+      strncpy (location, argv[1], sizeof (location) - 1);
+      location[sizeof (location) - 1] = '\0';
     }
 
   md_assemblef ("l.%c $ta,%s", size, argv[0]);
@@ -3287,8 +3287,8 @@ do_pseudo_pop_bhwd (int argc ATTRIBUTE_UNUSED, char *argv[],
 
   if (argc == 3)
     {
-      strncpy (location, argv[2], 8);
-      location[7] = '\0';
+      strncpy (location, argv[2], sizeof (location) - 1);
+      location[sizeof (location) - 1] = '\0';
     }
 
   if ((pv & 0x3) == 0x3) /* double-word */
@@ -3310,8 +3310,8 @@ do_pseudo_pusha (int argc ATTRIBUTE_UNUSED, char *argv[],
 
   if (argc == 2)
     {
-      strncpy (location, argv[1], 8);
-      location[7] = '\0';
+      strncpy (location, argv[1], sizeof (location) - 1);
+      location[sizeof (location) - 1] = '\0';
     }
 
   md_assemblef ("la $ta,%s", argv[0]);
@@ -3327,8 +3327,8 @@ do_pseudo_pushi (int argc ATTRIBUTE_UNUSED, char *argv[],
 
   if (argc == 2)
     {
-      strncpy (location, argv[1], 8);
-      location[7] = '\0';
+      strncpy (location, argv[1], sizeof (location) - 1);
+      location[sizeof (location) - 1] = '\0';
     }
 
   md_assemblef ("li $ta,%s", argv[0]);

-- 
Alan Modra
Australia Development Lab, IBM

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

only message in thread, other threads:[~2021-05-27  1:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-27  1:27 nds32: __builtin_strncpy bound equals destination size 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).