From: Greg Kroah-Hartman Date: Thu, 6 Dec 2018 07:03:32 +0000 (+0100) Subject: 4.19-stable patches X-Git-Tag: v4.19.8~30 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=217b26741e3d215f8408c06579ece0d370ca4630;p=thirdparty%2Fkernel%2Fstable-queue.git 4.19-stable patches added patches: unifdef-use-memcpy-instead-of-strncpy.patch --- diff --git a/queue-4.19/series b/queue-4.19/series index 0738ea788d7..0a0e2dca9f3 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -1,2 +1,3 @@ blk-mq-fix-corruption-with-direct-issue.patch test_hexdump-use-memcpy-instead-of-strncpy.patch +unifdef-use-memcpy-instead-of-strncpy.patch diff --git a/queue-4.19/unifdef-use-memcpy-instead-of-strncpy.patch b/queue-4.19/unifdef-use-memcpy-instead-of-strncpy.patch new file mode 100644 index 00000000000..a0ff78a1d07 --- /dev/null +++ b/queue-4.19/unifdef-use-memcpy-instead-of-strncpy.patch @@ -0,0 +1,46 @@ +From 38c7b224ce22c25fed04007839edf974bd13439d Mon Sep 17 00:00:00 2001 +From: Linus Torvalds +Date: Fri, 30 Nov 2018 14:45:01 -0800 +Subject: unifdef: use memcpy instead of strncpy + +From: Linus Torvalds + +commit 38c7b224ce22c25fed04007839edf974bd13439d upstream. + +New versions of gcc reasonably warn about the odd pattern of + + strncpy(p, q, strlen(q)); + +which really doesn't make sense: the strncpy() ends up being just a slow +and odd way to write memcpy() in this case. + +There was a comment about _why_ the code used strncpy - to avoid the +terminating NUL byte, but memcpy does the same and avoids the warning. + +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + +--- + scripts/unifdef.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/scripts/unifdef.c ++++ b/scripts/unifdef.c +@@ -395,7 +395,7 @@ usage(void) + * When we have processed a group that starts off with a known-false + * #if/#elif sequence (which has therefore been deleted) followed by a + * #elif that we don't understand and therefore must keep, we edit the +- * latter into a #if to keep the nesting correct. We use strncpy() to ++ * latter into a #if to keep the nesting correct. We use memcpy() to + * overwrite the 4 byte token "elif" with "if " without a '\0' byte. + * + * When we find a true #elif in a group, the following block will +@@ -450,7 +450,7 @@ static void Idrop (void) { Fdrop(); ign + static void Itrue (void) { Ftrue(); ignoreon(); } + static void Ifalse(void) { Ffalse(); ignoreon(); } + /* modify this line */ +-static void Mpass (void) { strncpy(keyword, "if ", 4); Pelif(); } ++static void Mpass (void) { memcpy(keyword, "if ", 4); Pelif(); } + static void Mtrue (void) { keywordedit("else"); state(IS_TRUE_MIDDLE); } + static void Melif (void) { keywordedit("endif"); state(IS_FALSE_TRAILER); } + static void Melse (void) { keywordedit("endif"); state(IS_FALSE_ELSE); }