From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 89AD0A04F6 for ; Tue, 7 Jan 2020 12:29:41 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7BBDA1D724; Tue, 7 Jan 2020 12:29:41 +0100 (CET) Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by dpdk.org (Postfix) with ESMTP id E9D351C43F for ; Tue, 7 Jan 2020 12:29:40 +0100 (CET) Received: by mail-wr1-f66.google.com with SMTP id z7so53447556wrl.13 for ; Tue, 07 Jan 2020 03:29:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:content-transfer-encoding:user-agent:mime-version; bh=c4Llb/IJ2aeJqndyYTG9RMxskfaODUHYMQhyarWBvPE=; b=F+HU2Gcf1vNV5ztdPxGCX11QMegIAGw4OI3PSns0+6evBcEUiqddgRF0JXpoYbt5xw A1brrwayTTPnPComOwjjWLWL9aOSRmyhIxEtYkVvwi5dUgEu7ZvUQgAzRz83FjKA9xGv SZxfUDHy1nMN20mDyNRnrZ7z/n1e3FOrRbN6Z/ZY6KU9g8S/wsITjfwGkHH8QMUvP1E1 Ve3fYUFWmeOEzwfcUd0XYIfv1ESmv1wCx6f2fYcKHVdSQckSRZLUz02x0tZqy0Li2mva tIPkzQC/lvi96PuZMYO3exvy6znH/mmafGZQpa6oSR8FruEZnKIhf7G/1CeLZ9Pko7We Eulw== X-Gm-Message-State: APjAAAU0IwqgwnhoJPVj6wnQIvo9L714yWGNHLAVkvnJRAfG9SFEwtWS SJ3yBc6WoJBlknpx/Jubv5U= X-Google-Smtp-Source: APXvYqw1jvyrB6NCExMCd6sMt9OrMffpTE405FO1cXDlN86JlhSdTl3PwHtsz0bxz/iLBIXHFmtuNQ== X-Received: by 2002:a5d:4807:: with SMTP id l7mr110763169wrq.64.1578396580610; Tue, 07 Jan 2020 03:29:40 -0800 (PST) Received: from localhost ([88.98.246.218]) by smtp.gmail.com with ESMTPSA id z83sm26695160wmg.2.2020.01.07.03.29.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 03:29:39 -0800 (PST) Message-ID: <42d6003a11887ad96314d36e8ab0c01c2155dc27.camel@debian.org> From: Luca Boccassi To: "Tahhan, Maryam" , "Power, Ciara" , "stable@dpdk.org" Cc: "Pattan, Reshma" , "romanx.korynkevych@intel.com" Date: Tue, 07 Jan 2020 11:29:39 +0000 In-Reply-To: References: <20200106114254.54945-1-ciara.power@intel.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.30.5-1.1 MIME-Version: 1.0 Subject: Re: [dpdk-stable] [PATCH 17.11] app/proc_info: fix string copying to use strlcpy X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" On Mon, 2020-01-06 at 12:53 +0000, Tahhan, Maryam wrote: > > [ upstream commit 7edbf7ddfd7d2453afaad3b72666491d30b616af ] > >=20 > > Replaced strncpy and strcpy with strlcpy. > > Using strlcpy is safe practice when copying strings, as it will > > include a null > > terminator. > >=20 > > Cc: romanx.korynkevych@intel.com > >=20 > > Fixes: 2deb6b5246d7 ("app/procinfo: add collectd format and host > > id") > > Reported-by: Reshma Pattan > >=20 > > Signed-off-by: Ciara Power > > Acked-by: Bruce Richardson > > --- > > app/proc_info/main.c | 36 ++++++++++++++++++------------------ > > 1 file changed, 18 insertions(+), 18 deletions(-) > >=20 > > diff --git a/app/proc_info/main.c b/app/proc_info/main.c index > > 2893bec69..caf4e48c0 100644 > > --- a/app/proc_info/main.c > > +++ b/app/proc_info/main.c > > @@ -196,7 +196,7 @@ proc_info_preparse_args(int argc, char **argv) > > int err =3D gethostname(host_id, MAX_LONG_OPT_SZ-1); > >=20 > > if (err) > > - strcpy(host_id, "unknown"); > > + strlcpy(host_id, "unknown", sizeof(host_id)); > > } > >=20 > > return 0; > > @@ -363,50 +363,50 @@ static void collectd_resolve_cnt_type(char > > *cnt_type, size_t cnt_type_len, > > if ((type_end !=3D NULL) && > > (strncmp(cnt_name, "rx_", strlen("rx_")) =3D=3D 0)) { > > if (strncmp(type_end, "_errors", strlen("_errors")) =3D=3D > > 0) > > - strncpy(cnt_type, "if_rx_errors", > > cnt_type_len); > > + strlcpy(cnt_type, "if_rx_errors", > > cnt_type_len); > > else if (strncmp(type_end, "_dropped", > > strlen("_dropped")) > > =3D=3D 0) > > - strncpy(cnt_type, "if_rx_dropped", > > cnt_type_len); > > + strlcpy(cnt_type, "if_rx_dropped", > > cnt_type_len); > > else if (strncmp(type_end, "_bytes", strlen("_bytes")) > > =3D=3D 0) > > - strncpy(cnt_type, "if_rx_octets", > > cnt_type_len); > > + strlcpy(cnt_type, "if_rx_octets", > > cnt_type_len); > > else if (strncmp(type_end, "_packets", > > strlen("_packets")) > > =3D=3D 0) > > - strncpy(cnt_type, "if_rx_packets", > > cnt_type_len); > > + strlcpy(cnt_type, "if_rx_packets", > > cnt_type_len); > > else if (strncmp(type_end, "_placement", > > strlen("_placement")) =3D=3D 0) > > - strncpy(cnt_type, "if_rx_errors", > > cnt_type_len); > > + strlcpy(cnt_type, "if_rx_errors", > > cnt_type_len); > > else if (strncmp(type_end, "_buff", strlen("_buff")) =3D=3D > > 0) > > - strncpy(cnt_type, "if_rx_errors", > > cnt_type_len); > > + strlcpy(cnt_type, "if_rx_errors", > > cnt_type_len); > > else > > /* Does not fit obvious type: use a more > > generic one > > */ > > - strncpy(cnt_type, "derive", cnt_type_len); > > + strlcpy(cnt_type, "derive", cnt_type_len); > > } else if ((type_end !=3D NULL) && > > (strncmp(cnt_name, "tx_", strlen("tx_"))) =3D=3D 0) { > > if (strncmp(type_end, "_errors", strlen("_errors")) =3D=3D > > 0) > > - strncpy(cnt_type, "if_tx_errors", > > cnt_type_len); > > + strlcpy(cnt_type, "if_tx_errors", > > cnt_type_len); > > else if (strncmp(type_end, "_dropped", > > strlen("_dropped")) > > =3D=3D 0) > > - strncpy(cnt_type, "if_tx_dropped", > > cnt_type_len); > > + strlcpy(cnt_type, "if_tx_dropped", > > cnt_type_len); > > else if (strncmp(type_end, "_bytes", strlen("_bytes")) > > =3D=3D 0) > > - strncpy(cnt_type, "if_tx_octets", > > cnt_type_len); > > + strlcpy(cnt_type, "if_tx_octets", > > cnt_type_len); > > else if (strncmp(type_end, "_packets", > > strlen("_packets")) > > =3D=3D 0) > > - strncpy(cnt_type, "if_tx_packets", > > cnt_type_len); > > + strlcpy(cnt_type, "if_tx_packets", > > cnt_type_len); > > else > > /* Does not fit obvious type: use a more > > generic one > > */ > > - strncpy(cnt_type, "derive", cnt_type_len); > > + strlcpy(cnt_type, "derive", cnt_type_len); > > } else if ((type_end !=3D NULL) && > > (strncmp(cnt_name, "flow_", strlen("flow_"))) =3D=3D 0) > > { > > if (strncmp(type_end, "_filters", strlen("_filters")) > > =3D=3D 0) > > - strncpy(cnt_type, "operations", cnt_type_len); > > + strlcpy(cnt_type, "operations", cnt_type_len); > > else if (strncmp(type_end, "_errors", > > strlen("_errors")) =3D=3D 0) > > - strncpy(cnt_type, "errors", cnt_type_len); > > + strlcpy(cnt_type, "errors", cnt_type_len); > > else if (strncmp(type_end, "_filters", > > strlen("_filters")) =3D=3D 0) > > - strncpy(cnt_type, "filter_result", > > cnt_type_len); > > + strlcpy(cnt_type, "filter_result", > > cnt_type_len); > > } else if ((type_end !=3D NULL) && > > (strncmp(cnt_name, "mac_", strlen("mac_"))) =3D=3D 0) { > > if (strncmp(type_end, "_errors", strlen("_errors")) =3D=3D > > 0) > > - strncpy(cnt_type, "errors", cnt_type_len); > > + strlcpy(cnt_type, "errors", cnt_type_len); > > } else { > > /* Does not fit obvious type, or strrchr error: */ > > /* use a more generic type */ > > - strncpy(cnt_type, "derive", cnt_type_len); > > + strlcpy(cnt_type, "derive", cnt_type_len); > > } > > } > >=20 > > -- > > 2.17.1 >=20 > Acked-by: Maryam Tahhan =20 Thanks, applied --=20 Kind regards, Luca Boccassi