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 426BEA056A for ; Fri, 6 Mar 2020 13:07:16 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 292751BFE9; Fri, 6 Mar 2020 13:07:16 +0100 (CET) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by dpdk.org (Postfix) with ESMTP id DECF91BFDD for ; Fri, 6 Mar 2020 13:07:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583496432; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=J7Igk8iQFm+n64lZujt9FQZgcMft9+hJcvPym4Y9MqU=; b=O/wHFCnMWgNkOv0wVXuBZujqtzLXDkV3cGqSirFv+zCC/orn/dj6ch54ACZf09mYZQgct4 G0A4wLsdYZ9xREQbncGZHK+pO+S1THe/Q90VSFIKUhCEaVhlivT5omrm98G1kIEuj0gc+7 lhEjULdk86tz/+TtwmXQkhgYMdoKVWg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-376-qmo6654IN0qMuVFnVxPotg-1; Fri, 06 Mar 2020 07:07:11 -0500 X-MC-Unique: qmo6654IN0qMuVFnVxPotg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C24DC18A8C80; Fri, 6 Mar 2020 12:07:09 +0000 (UTC) Received: from rh.redhat.com (unknown [10.33.36.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 48B6560BEC; Fri, 6 Mar 2020 12:07:05 +0000 (UTC) From: Kevin Traynor To: dev@dpdk.org Cc: Kevin Traynor , stable@dpdk.org, xuanziyang2@huawei.com, cloud.wangxiaoyun@huawei.com, zhouguoyang@huawei.com Date: Fri, 6 Mar 2020 12:06:52 +0000 Message-Id: <20200306120652.30080-2-ktraynor@redhat.com> In-Reply-To: <20200306120652.30080-1-ktraynor@redhat.com> References: <20200306120047.29392-1-ktraynor@redhat.com> <20200306120652.30080-1-ktraynor@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [dpdk-stable] [PATCH v2 2/2] net/hinic: fix repeating log and length check 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" gcc 10.0.1 reports: ../drivers/net/hinic/base/hinic_pmd_hwdev.c: In function =E2=80=98print_cab= le_info=E2=80=99: ../drivers/net/hinic/base/hinic_pmd_hwdev.c:1398:3: warning: =E2=80=98snprintf=E2=80=99 argument 4 may overlap destination object =E2=80= =98tmp_str=E2=80=99 [-Wrestrict] 1398 | snprintf(tmp_str + strlen(tmp_str), (sizeof(tmp_str) - 1), | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1399 | "%s, Temperature: %u", tmp_str, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1400 | info->cable_temp); | ~~~~~~~~~~~~~~~~~ The warning is that tmp_str is in both src and dest. Anyway, the current code is incorrect and because of the +strlen the existing string will be repeated twice and max length does not limit to the end of the string. Fix by removing tmp_str from the src of snprintf and adding the correct max length. Fixes: d9ce1917941c ("net/hinic/base: add hardware operation") Cc: stable@dpdk.org Signed-off-by: Kevin Traynor --- Cc: xuanziyang2@huawei.com Cc: cloud.wangxiaoyun@huawei.com Cc: zhouguoyang@huawei.com --- drivers/net/hinic/base/hinic_pmd_hwdev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/hinic/base/hinic_pmd_hwdev.c b/drivers/net/hinic/b= ase/hinic_pmd_hwdev.c index b6c821a2a..fd0292f84 100644 --- a/drivers/net/hinic/base/hinic_pmd_hwdev.c +++ b/drivers/net/hinic/base/hinic_pmd_hwdev.c @@ -1396,7 +1396,7 @@ static void print_cable_info(struct hinic_link_info *= info) =09=09 info->cable_length, info->cable_max_speed); =09if (info->port_type !=3D LINK_PORT_COPPER) -=09=09snprintf(tmp_str + strlen(tmp_str), (sizeof(tmp_str) - 1), -=09=09=09 "%s, Temperature: %u", tmp_str, -=09=09=09 info->cable_temp); +=09=09snprintf(tmp_str + strlen(tmp_str), +=09=09=09 sizeof(tmp_str) - strlen(tmp_str), +=09=09=09 ", Temperature: %u", info->cable_temp); =20 =09PMD_DRV_LOG(INFO, "Cable information: %s", tmp_str); --=20 2.21.1