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 4ED36A04AF; Fri, 14 Aug 2020 17:01:22 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 309A41C0CE; Fri, 14 Aug 2020 17:01:22 +0200 (CEST) Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) by dpdk.org (Postfix) with ESMTP id 5555C1C0C3 for ; Fri, 14 Aug 2020 17:01:20 +0200 (CEST) Received: by mail-pj1-f65.google.com with SMTP id 2so4520847pjx.5 for ; Fri, 14 Aug 2020 08:01:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Do6xTsWQg70vnrR09H/I5pVLFVHIcL6ET9aD3EifBTA=; b=AWz0+fxf4AP1NOO0DsjuJ5A2LSO69i9kSQW8QIVr0Fcv1kKLU95w00uMIVR2/zAXIG 2Bq+XFbyqMmbetpEKn6XwmGrrOZml4GA7E1u4+v4MChtofBXq494d+vq/mKkmjg67m+C O7f5Id72RYy9CvV2PMBa01BebiL3UwzxGOHGTpKSEDfF5Dh45eK8h8nsYDsVCHrREy9/ MeYgoR1OErqzoR/AxS9TE9Ak8BrioekhO5OdR1ud4RoQoBP47x7boHGl2+h/+1tbXKBP LrV3b9SFpa80RlnDEmy6ZjJwAdrzhKS3++TlXdSMtu+V03Iavql32B2fbuI/vFRvYJR0 pGuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Do6xTsWQg70vnrR09H/I5pVLFVHIcL6ET9aD3EifBTA=; b=dnqi2EhBTJGzrxWR4DXqPS+mIIDzxBgF0KVas1cQyGldg5SSZz0PRsRKlczimAuq8T L+k1uDRBrb3kLxCUbhl8XPkSr020dMReNwWjHxLwtNiEijtq8kr68RdFkPm47wojxvst XM6A4WmiY1dVm8UsCFbCnkJtUbniRA5mAKmMBdDvX/qe0fWeBe7+BdQDizhazcuN26xe Q8FBO/HTMwjhUJc7X+6DjBkYmrAj9xm/f4sWSJGHyf94Q4EkPpdc5aHhJZK9RVNaaDjs tQQMby8H5z01YoIwlctEcEX33OKilIEEB3+L9+1Px8B31gwHPPMZvrnMwqFaTbluGqVg C7Hg== X-Gm-Message-State: AOAM532kZkmVEbrElkXTUlKncqbA46kQ0rsn4q+IFdbQWJXyCa++vT/H OyAKvS8JRVBYAcCiuhtxwPQorA== X-Google-Smtp-Source: ABdhPJzQqQz7PvHnmiK6yl8cKt47plJi6CDXzfWj2+NZCG1FbgocJNyDRT4CG5mvCvgtKtZhmKylFw== X-Received: by 2002:a17:90a:fe83:: with SMTP id co3mr2592258pjb.64.1597417279453; Fri, 14 Aug 2020 08:01:19 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id d23sm4300892pgm.11.2020.08.14.08.01.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2020 08:01:19 -0700 (PDT) Date: Fri, 14 Aug 2020 08:01:16 -0700 From: Stephen Hemminger To: Bruce Richardson Cc: dev@dpdk.org, stable@dpdk.org, Anatoly Burakov Message-ID: <20200814080116.37da0f89@hermes.lan> In-Reply-To: <20200814110045.217724-4-bruce.richardson@intel.com> References: <20200814110045.217724-1-bruce.richardson@intel.com> <20200814110045.217724-4-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [dpdk-dev] [PATCH 3/4] examples/mp_server: fix snprintf overflow X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Fri, 14 Aug 2020 12:00:44 +0100 Bruce Richardson wrote: > When producing a printable mac address the buffer was appropriately sized > for holding the mac address exactly, but the actual snprintf included a > '\n' character at the end, which means that the snprintf technically is > getting truncated i.e. the \n would not be added due to lack of space. > This gets flagged as a problem by modern versions of gcc, e.g. on Ubuntu > 20.04. >=20 > main.c:77:37: warning: =E2=80=98__builtin___snprintf_chk=E2=80=99 output = truncated before the last format character [-Wformat-truncation=3D] > 77 | "%02x:%02x:%02x:%02x:%02x:%02x\n", > | ^ >=20 > Since the \n is getting stripped anyway, we can fix the issue by just > removing it from the printf string. >=20 > Fixes: af75078fece3 ("first public release") > Cc: stable@dpdk.org >=20 > Signed-off-by: Bruce Richardson > --- > examples/multi_process/client_server_mp/mp_server/main.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/examples/multi_process/client_server_mp/mp_server/main.c b/e= xamples/multi_process/client_server_mp/mp_server/main.c > index 280dab8672..af5af672c3 100644 > --- a/examples/multi_process/client_server_mp/mp_server/main.c > +++ b/examples/multi_process/client_server_mp/mp_server/main.c > @@ -74,7 +74,7 @@ get_printable_mac_addr(uint16_t port) > return err_address; > } > snprintf(addresses[port], sizeof(addresses[port]), > - "%02x:%02x:%02x:%02x:%02x:%02x\n", > + "%02x:%02x:%02x:%02x:%02x:%02x", > mac.addr_bytes[0], mac.addr_bytes[1], mac.addr_bytes[2], > mac.addr_bytes[3], mac.addr_bytes[4], mac.addr_bytes[5]); > } Please convert to rte_ether_format_addr() instead of local hard coded forma= t.