From: Alan Modra Date: Wed, 26 May 2021 12:53:44 +0000 (+0930) Subject: nds32: __builtin_strncpy bound equals destination size X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=badf836a0c727608d7660949bf353525ee2d8252;p=binutils-gdb.git nds32: __builtin_strncpy bound equals destination size * 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/ChangeLog b/gas/ChangeLog index 31f9e36ce9a..d2f5f764387 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,9 @@ +2021-05-27 Alan Modra + + * config/tc-nds32.c (do_pseudo_push_bhwd, do_pseudo_pop_bhwd), + (do_pseudo_pusha, do_pseudo_pushi): Avoid fortify strncpy bound + error. + 2021-05-26 H.J. Lu PR ld/27905 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]);