{"id":808822,"url":"http://patchwork.ozlabs.org/api/1.0/patches/808822/?format=json","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/1.0/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<20170901165256.21459-4-phil@nwl.cc>","date":"2017-09-01T16:52:53","name":"[iproute,3/6] Convert harmful calls to strncpy() to strlcpy()","commit_ref":null,"pull_url":null,"state":"accepted","archived":true,"hash":"7a6b018ff501a8b29922dac20f18012a50adf0bf","submitter":{"id":4285,"url":"http://patchwork.ozlabs.org/api/1.0/people/4285/?format=json","name":"Phil Sutter","email":"phil@nwl.cc"},"delegate":{"id":389,"url":"http://patchwork.ozlabs.org/api/1.0/users/389/?format=json","username":"shemminger","first_name":"stephen","last_name":"hemminger","email":"shemminger@vyatta.com"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/20170901165256.21459-4-phil@nwl.cc/mbox/","series":[{"id":1076,"url":"http://patchwork.ozlabs.org/api/1.0/series/1076/?format=json","date":"2017-09-01T16:52:50","name":"strlcpy() and strlcat() for iproute2","version":1,"mbox":"http://patchwork.ozlabs.org/series/1076/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/808822/checks/","tags":{},"headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xkQLQ0ZCQz9t3F\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat,  2 Sep 2017 02:53:50 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1752271AbdIAQxs (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tFri, 1 Sep 2017 12:53:48 -0400","from orbyte.nwl.cc ([151.80.46.58]:59865 \"EHLO mail.nwl.cc\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1752247AbdIAQxq (ORCPT <rfc822;netdev@vger.kernel.org>);\n\tFri, 1 Sep 2017 12:53:46 -0400","from mail.nwl.cc (orbyte.nwl.cc [127.0.0.1])\n\tby mail.nwl.cc (Postfix) with ESMTP id 883A565A5E;\n\tFri,  1 Sep 2017 18:53:45 +0200 (CEST)","from xsao (localhost [IPv6:::1])\n\tby mail.nwl.cc (Postfix) with ESMTP id 6A4BF644CF;\n\tFri,  1 Sep 2017 18:53:45 +0200 (CEST)"],"From":"Phil Sutter <phil@nwl.cc>","To":"Stephen Hemminger <stephen@networkplumber.org>","Cc":"netdev@vger.kernel.org","Subject":"[iproute PATCH 3/6] Convert harmful calls to strncpy() to strlcpy()","Date":"Fri,  1 Sep 2017 18:52:53 +0200","Message-Id":"<20170901165256.21459-4-phil@nwl.cc>","X-Mailer":"git-send-email 2.13.1","In-Reply-To":"<20170901165256.21459-1-phil@nwl.cc>","References":"<20170901165256.21459-1-phil@nwl.cc>","X-Virus-Scanned":"ClamAV using ClamSMTP","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"This patch converts spots where manual buffer termination was missing to\nstrlcpy() since that does what is needed.\n\nSigned-off-by: Phil Sutter <phil@nwl.cc>\n---\n genl/ctrl.c     | 2 +-\n ip/ipvrf.c      | 2 +-\n ip/xfrm_state.c | 2 +-\n 3 files changed, 3 insertions(+), 3 deletions(-)","diff":"diff --git a/genl/ctrl.c b/genl/ctrl.c\nindex 6abd52582d0d3..448988eb90e2b 100644\n--- a/genl/ctrl.c\n+++ b/genl/ctrl.c\n@@ -313,7 +313,7 @@ static int ctrl_list(int cmd, int argc, char **argv)\n \n \t\tif (matches(*argv, \"name\") == 0) {\n \t\t\tNEXT_ARG();\n-\t\t\tstrncpy(d, *argv, sizeof (d) - 1);\n+\t\t\tstrlcpy(d, *argv, sizeof(d));\n \t\t\taddattr_l(nlh, 128, CTRL_ATTR_FAMILY_NAME,\n \t\t\t\t  d, strlen(d) + 1);\n \t\t} else if (matches(*argv, \"id\") == 0) {\ndiff --git a/ip/ipvrf.c b/ip/ipvrf.c\nindex b74c501e0970c..f9277e1e66bdf 100644\n--- a/ip/ipvrf.c\n+++ b/ip/ipvrf.c\n@@ -74,7 +74,7 @@ static int vrf_identify(pid_t pid, char *name, size_t len)\n \t\t\tif (end)\n \t\t\t\t*end = '\\0';\n \n-\t\t\tstrncpy(name, vrf, len - 1);\n+\t\t\tstrlcpy(name, vrf, len);\n \t\t\tbreak;\n \t\t}\n \t}\ndiff --git a/ip/xfrm_state.c b/ip/xfrm_state.c\nindex e11c93bf1c3b5..4483fb8f71d2c 100644\n--- a/ip/xfrm_state.c\n+++ b/ip/xfrm_state.c\n@@ -125,7 +125,7 @@ static int xfrm_algo_parse(struct xfrm_algo *alg, enum xfrm_attr_type_t type,\n \tfprintf(stderr, \"warning: ALGO-NAME/ALGO-KEYMAT values will be sent to the kernel promiscuously! (verifying them isn't implemented yet)\\n\");\n #endif\n \n-\tstrncpy(alg->alg_name, name, sizeof(alg->alg_name));\n+\tstrlcpy(alg->alg_name, name, sizeof(alg->alg_name));\n \n \tif (slen > 2 && strncmp(key, \"0x\", 2) == 0) {\n \t\t/* split two chars \"0x\" from the top */\n","prefixes":["iproute","3/6"]}