{"id":808818,"url":"http://patchwork.ozlabs.org/api/1.0/patches/808818/?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-5-phil@nwl.cc>","date":"2017-09-01T16:52:54","name":"[iproute,4/6] ipxfrm: Replace STRBUF_CAT macro with strlcat()","commit_ref":null,"pull_url":null,"state":"accepted","archived":true,"hash":"8dfab03ae4accc3ff7d8ba58b01d482f2a60f9b1","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-5-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/808818/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 3xkQKw6pMCz9t2x\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat,  2 Sep 2017 02:53:24 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1752173AbdIAQxW (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tFri, 1 Sep 2017 12:53:22 -0400","from orbyte.nwl.cc ([151.80.46.58]:52195 \"EHLO mail.nwl.cc\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1752148AbdIAQxV (ORCPT <rfc822;netdev@vger.kernel.org>);\n\tFri, 1 Sep 2017 12:53:21 -0400","from mail.nwl.cc (orbyte.nwl.cc [127.0.0.1])\n\tby mail.nwl.cc (Postfix) with ESMTP id 806BB65A5E;\n\tFri,  1 Sep 2017 18:53:20 +0200 (CEST)","from xsao (localhost [IPv6:::1])\n\tby mail.nwl.cc (Postfix) with ESMTP id 64B0E644CF;\n\tFri,  1 Sep 2017 18:53:20 +0200 (CEST)"],"From":"Phil Sutter <phil@nwl.cc>","To":"Stephen Hemminger <stephen@networkplumber.org>","Cc":"netdev@vger.kernel.org","Subject":"[iproute PATCH 4/6] ipxfrm: Replace STRBUF_CAT macro with strlcat()","Date":"Fri,  1 Sep 2017 18:52:54 +0200","Message-Id":"<20170901165256.21459-5-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":"Signed-off-by: Phil Sutter <phil@nwl.cc>\n---\n ip/ipxfrm.c | 21 +++++----------------\n 1 file changed, 5 insertions(+), 16 deletions(-)","diff":"diff --git a/ip/ipxfrm.c b/ip/ipxfrm.c\nindex d5eb22e25476a..12c2f721571b6 100644\n--- a/ip/ipxfrm.c\n+++ b/ip/ipxfrm.c\n@@ -40,17 +40,6 @@\n #include \"ip_common.h\"\n \n #define STRBUF_SIZE\t(128)\n-#define STRBUF_CAT(buf, str) \\\n-\tdo { \\\n-\t\tint rest = sizeof(buf) - 1 - strlen(buf); \\\n-\t\tif (rest > 0) { \\\n-\t\t\tint len = strlen(str); \\\n-\t\t\tif (len > rest) \\\n-\t\t\t\tlen = rest; \\\n-\t\t\tstrncat(buf, str, len); \\\n-\t\t\tbuf[sizeof(buf) - 1] = '\\0'; \\\n-\t\t} \\\n-\t} while (0);\n \n struct xfrm_filter filter;\n \n@@ -902,8 +891,8 @@ void xfrm_state_info_print(struct xfrm_usersa_info *xsinfo,\n \t\t\t   prefix, title);\n \n \tif (prefix)\n-\t\tSTRBUF_CAT(buf, prefix);\n-\tSTRBUF_CAT(buf, \"\\t\");\n+\t\tstrlcat(buf, prefix, sizeof(buf));\n+\tstrlcat(buf, \"\\t\", sizeof(buf));\n \n \tfputs(buf, fp);\n \tfprintf(fp, \"replay-window %u \", xsinfo->replay_window);\n@@ -944,7 +933,7 @@ void xfrm_state_info_print(struct xfrm_usersa_info *xsinfo,\n \t\tchar sbuf[STRBUF_SIZE];\n \n \t\tmemcpy(sbuf, buf, sizeof(sbuf));\n-\t\tSTRBUF_CAT(sbuf, \"sel \");\n+\t\tstrlcat(sbuf, \"sel \", sizeof(sbuf));\n \n \t\txfrm_selector_print(&xsinfo->sel, xsinfo->family, fp, sbuf);\n \t}\n@@ -992,8 +981,8 @@ void xfrm_policy_info_print(struct xfrm_userpolicy_info *xpinfo,\n \t}\n \n \tif (prefix)\n-\t\tSTRBUF_CAT(buf, prefix);\n-\tSTRBUF_CAT(buf, \"\\t\");\n+\t\tstrlcat(buf, prefix, sizeof(buf));\n+\tstrlcat(buf, \"\\t\", sizeof(buf));\n \n \tfputs(buf, fp);\n \tif (xpinfo->dir >= XFRM_POLICY_MAX) {\n","prefixes":["iproute","4/6"]}