From ecb0b8409c86cc3e23ca57168cb072183b380d7c Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 6 Dec 2018 13:49:11 +0100 Subject: [PATCH] 4.19-stable patches added patches: tipc-use-destination-length-for-copy-string.patch --- queue-4.19/series | 1 + ...e-destination-length-for-copy-string.patch | 41 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 queue-4.19/tipc-use-destination-length-for-copy-string.patch diff --git a/queue-4.19/series b/queue-4.19/series index 5be174bf6ef..b68896652d1 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -38,3 +38,4 @@ input-elan_i2c-add-support-for-elan0621-touchpad.patch btrfs-tree-checker-don-t-check-max-block-group-size-as-current-max-chunk-size-limit-is-unreliable.patch arc-change-defconfig-defaults-to-arcv2.patch arc-add-support-of-nfsv3-acl.patch +tipc-use-destination-length-for-copy-string.patch diff --git a/queue-4.19/tipc-use-destination-length-for-copy-string.patch b/queue-4.19/tipc-use-destination-length-for-copy-string.patch new file mode 100644 index 00000000000..dc1ff7ff51f --- /dev/null +++ b/queue-4.19/tipc-use-destination-length-for-copy-string.patch @@ -0,0 +1,41 @@ +From 29e270fc32192e7729057963ae7120663856c93e Mon Sep 17 00:00:00 2001 +From: Guoqing Jiang +Date: Fri, 19 Oct 2018 12:08:22 +0800 +Subject: tipc: use destination length for copy string +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Guoqing Jiang + +commit 29e270fc32192e7729057963ae7120663856c93e upstream. + +Got below warning with gcc 8.2 compiler. + +net/tipc/topsrv.c: In function ‘tipc_topsrv_start’: +net/tipc/topsrv.c:660:2: warning: ‘strncpy’ specified bound depends on the length of the source argument [-Wstringop-overflow=] + strncpy(srv->name, name, strlen(name) + 1); + ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +net/tipc/topsrv.c:660:27: note: length computed here + strncpy(srv->name, name, strlen(name) + 1); + ^~~~~~~~~~~~ +So change it to correct length and use strscpy. + +Signed-off-by: Guoqing Jiang +Acked-by: Ying Xue +Signed-off-by: David S. Miller +Signed-off-by: Greg Kroah-Hartman + +diff --git a/net/tipc/topsrv.c b/net/tipc/topsrv.c +index d8956f7daac4..4bdea0057171 100644 +--- a/net/tipc/topsrv.c ++++ b/net/tipc/topsrv.c +@@ -651,7 +651,7 @@ int tipc_topsrv_start(struct net *net) + srv->max_rcvbuf_size = sizeof(struct tipc_subscr); + INIT_WORK(&srv->awork, tipc_topsrv_accept); + +- strncpy(srv->name, name, strlen(name) + 1); ++ strscpy(srv->name, name, sizeof(srv->name)); + tn->topsrv = srv; + atomic_set(&tn->subscription_count, 0); + -- 2.47.3