From 4aeba1b7659603e49b8edfc0d64aa7790d2ef3fe Mon Sep 17 00:00:00 2001 From: Andreas Krebbel Date: Mon, 18 Dec 2017 11:31:06 +0000 Subject: [PATCH] S/390: PR83420: Improve hotpatch option parsing. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit With the attached patch we get rid of the following build failure: /home/andreas/build/../gcc/gcc/config/s390/s390.c: In function ‘void s390_option_override()’: /home/andreas/build/../gcc/gcc/config/s390/s390.c:15361:16: error: ‘char* strncpy(char*, const char*, size_t)’ specified bound 256 equals destination size [-Werror=stringop-truncation] strncpy (s, opt->arg, 256); ~~~~~~~~^~~~~~~~~~~~~~~~~~ gcc/ChangeLog: 2017-12-18 Andreas Krebbel PR target/83420 * config/s390/s390.c (s390_option_override): Avoid strncpy. From-SVN: r255777 --- gcc/ChangeLog | 5 +++++ gcc/config/s390/s390.c | 9 ++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ab682443d3a..128374c1287 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2017-12-18 Andreas Krebbel + + PR target/83420 + * config/s390/s390.c (s390_option_override): Avoid strncpy. + 2017-12-18 Richard Biener PR tree-optimization/81877 diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c index 0b04ac026fb..6f2a1895f91 100644 --- a/gcc/config/s390/s390.c +++ b/gcc/config/s390/s390.c @@ -15357,16 +15357,11 @@ s390_option_override (void) { int val1; int val2; - char s[256]; - char *t; + char *s = strtok (ASTRDUP (opt->arg), ","); + char *t = strtok (NULL, "\0"); - strncpy (s, opt->arg, 256); - s[255] = 0; - t = strchr (s, ','); if (t != NULL) { - *t = 0; - t++; val1 = integral_argument (s); val2 = integral_argument (t); } -- 2.30.2