From: Greg Kroah-Hartman Date: Fri, 14 Dec 2018 08:35:50 +0000 (+0100) Subject: 4.9-stable patches X-Git-Tag: v4.19.10~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=53c427475e76cd7b6663964945ed52c23a3b65cf;p=thirdparty%2Fkernel%2Fstable-queue.git 4.9-stable patches added patches: staging-speakup-replace-strncpy-with-memcpy.patch --- diff --git a/queue-4.9/series b/queue-4.9/series index ba3287be2b9..79f298c56ec 100644 --- a/queue-4.9/series +++ b/queue-4.9/series @@ -48,3 +48,4 @@ hfsplus-do-not-free-node-before-using.patch debugobjects-avoid-recursive-calls-with-kmemleak.patch ocfs2-fix-potential-use-after-free.patch pstore-convert-console-write-to-use-write_buf.patch +staging-speakup-replace-strncpy-with-memcpy.patch diff --git a/queue-4.9/staging-speakup-replace-strncpy-with-memcpy.patch b/queue-4.9/staging-speakup-replace-strncpy-with-memcpy.patch new file mode 100644 index 00000000000..8ff2d6b0ab8 --- /dev/null +++ b/queue-4.9/staging-speakup-replace-strncpy-with-memcpy.patch @@ -0,0 +1,56 @@ +From fd29edc7232bc19f969e8f463138afc5472b3d5f Mon Sep 17 00:00:00 2001 +From: Guenter Roeck +Date: Sun, 1 Jul 2018 13:57:24 -0700 +Subject: staging: speakup: Replace strncpy with memcpy + +From: Guenter Roeck + +commit fd29edc7232bc19f969e8f463138afc5472b3d5f upstream. + +gcc 8.1.0 generates the following warnings. + +drivers/staging/speakup/kobjects.c: In function 'punc_store': +drivers/staging/speakup/kobjects.c:522:2: warning: + 'strncpy' output truncated before terminating nul + copying as many bytes from a string as its length +drivers/staging/speakup/kobjects.c:504:6: note: length computed here + +drivers/staging/speakup/kobjects.c: In function 'synth_store': +drivers/staging/speakup/kobjects.c:391:2: warning: + 'strncpy' output truncated before terminating nul + copying as many bytes from a string as its length +drivers/staging/speakup/kobjects.c:388:8: note: length computed here + +Using strncpy() is indeed less than perfect since the length of data to +be copied has already been determined with strlen(). Replace strncpy() +with memcpy() to address the warning and optimize the code a little. + +Signed-off-by: Guenter Roeck +Reviewed-by: Samuel Thibault +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/staging/speakup/kobjects.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/drivers/staging/speakup/kobjects.c ++++ b/drivers/staging/speakup/kobjects.c +@@ -387,7 +387,7 @@ static ssize_t synth_store(struct kobjec + len = strlen(buf); + if (len < 2 || len > 9) + return -EINVAL; +- strncpy(new_synth_name, buf, len); ++ memcpy(new_synth_name, buf, len); + if (new_synth_name[len - 1] == '\n') + len--; + new_synth_name[len] = '\0'; +@@ -517,7 +517,7 @@ static ssize_t punc_store(struct kobject + return -EINVAL; + } + +- strncpy(punc_buf, buf, x); ++ memcpy(punc_buf, buf, x); + + while (x && punc_buf[x - 1] == '\n') + x--;