From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 89AA148B5B for ; Thu, 20 Nov 2025 17:23:39 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7DCFA402F0; Thu, 20 Nov 2025 17:23:39 +0100 (CET) Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by mails.dpdk.org (Postfix) with ESMTP id D5697402D4 for ; Thu, 20 Nov 2025 17:23:35 +0100 (CET) Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-298039e00c2so13954635ad.3 for ; Thu, 20 Nov 2025 08:23:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1763655815; x=1764260615; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BAV57wDUV45aKAL0XKKVCh8ZsI+MeYnrrt8UIS4GUBo=; b=VC26jkNS7L01EuTkqQbhSc35wAZgXzhZ5oWLwHkt/WNNrWWDt2TyzTc1OlNqaCHTWB yCBv2Hdb69O4wpyd7vIrp6J5VaeQ5cAEmKXwIqRMdepsuQIkheOb2F6I8PanPdCXbUoU spcWDU4eNpqr3RAj8k+TncSWgHmdfbIf+ZBg1dg/rJxV9DhG3jzGS1hUltTsgi3zKdem XdR+lpv1EFHZznUIii4z7OX43120v5NpiBMhFp474myHl9SBwZWrKXoouM3zaYzkHfQy XORZg2X5sGQMg2kcKcVWQ7826mgfrpgzXans8zx1UyX5fALMUk4GwCucWfKXQJc//1Lh vBmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763655815; x=1764260615; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=BAV57wDUV45aKAL0XKKVCh8ZsI+MeYnrrt8UIS4GUBo=; b=X7CqWMU7ayY9IfBnC4TuwZ3mBex9378+Zfc7a6F9R6qgl2pTG1+C9P5pp1gvAotEzr b9GSWsCJXttL6jOeQ+xeeEyFGOSPsfEj74DhPEKWOTVp3Y5GpKBfEUip7OgA+rh7kysE QdeB3wkG/mr5pT6Lk8QdVvyjS6trFIImRbAD+tuJdese+DhuPq0FZPCtn86QtOEIvXvz sTgCRW8W+eAyY6LUL+88GSVzH2VEO+NYeE8OI8sUTP07nvOn/BBn+t5TMiMxvu+FGAcr dB0jdEiuTCGKrQ8zxgU+ygYMFinrK8icKEe5XT+4p3h5bobVuM4SAuWVRyYXVwOeNQbJ EgYw== X-Forwarded-Encrypted: i=1; AJvYcCWv+SaS+bYOzJOl31hMNpK2ndDUwbrVdXzpjS27OW/9j/ynv4XbJgCpmieB+iV0Kc+idPI5Hrc=@dpdk.org X-Gm-Message-State: AOJu0YyjR24uIPaOVd2XrZNMNWQJSUZ8RfVPT5PzgFw0Mg7oLgEofmXc RqdR7nbx1G5ZZUEmAsKBAnWOwACRDGqF8AaHis1U0qEBxaoJ88gTeiNY/KJCv3IZohQ= X-Gm-Gg: ASbGncunXyc2YqjMwyDgSTqbZduL3Xl5UUosmdLCyQYDMfW1y8Liy/UGEI4MfvQbueH H9mpi39ly/PTchpkfVmo04Q+HGq3bF+ZJ/w/IcI0Lf0qKqpIbG/pOJp/imy32wjk7TBC/M/2iut SOo+H2E93DcPPAkhhUiC14OkAMxPN46hxZmu/0Y7Whfg8zArmbnSFWa74erkteE7xwmpWvdJNVH VBLH9EklBTt+tp897aua8OethzRUgDjCPuFMZqIULzWsOjG4eSh+bnQ65b4YW+A0jhwY9Wyrlf1 ex/FKo/H7kARySbGOX7iVjQCYr37u7qgvkExnJQm7zCnvf4xDpSnwB+Ch1CMiKUAtEEJ8dPpaXJ yixZ1ATt/Eu6d8ZwLxWNiJ3IB7zy2HJW5Ca7zG9Y/thiEKyezTfeTdzTl706+F5oqdp5D/3bAM2 iJTdEurSPYfvPlma2YPjAsj2w5oCT1LU66w+qzJZT6Drk/FeAHRw== X-Google-Smtp-Source: AGHT+IHzY/zSs3N916P7DdZZB9UZT/RSTKNIA2sK2KiDqOrABMCYB98NTPaaME7wI04raQx9ET/lVw== X-Received: by 2002:a05:7022:fc0a:b0:119:e56c:18b8 with SMTP id a92af1059eb24-11c947fe1cfmr915389c88.32.1763655814470; Thu, 20 Nov 2025 08:23:34 -0800 (PST) Received: from phoenix.lan (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-11c93e3e945sm12096427c88.6.2025.11.20.08.23.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Nov 2025 08:23:34 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , maxime.coquelin@redhat.com, stable@dpdk.org, Bruce Richardson , Chenbo Xia , Adrian Moreno Subject: [PATCH v4 2/4] examples/vdpa: fix format overflow warning Date: Thu, 20 Nov 2025 08:22:00 -0800 Message-ID: <20251120162327.78062-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251120162327.78062-1-stephen@networkplumber.org> References: <20251110182209.104087-1-stephen@networkplumber.org> <20251120162327.78062-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 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 The ifname is limited to 128 characters, but it would allow up to 128 characters as prefix then could overflow creating ifname. Change to limit path prefix (iface) to 123 (128 - sizeof("1024")) to avoid possible format overflow ../examples/vdpa/main.c:501:76: warning: ‘snprintf’ output may be truncated before the last format character [-Wformat-truncation=] 501 | snprintf(vports[devcnt].ifname, MAX_PATH_LEN, "%s%d", | ^ ../examples/vdpa/main.c:501:25: note: ‘snprintf’ output between 2 and 139 bytes into a destination of size 128 501 | snprintf(vports[devcnt].ifname, MAX_PATH_LEN, "%s%d", | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 502 | iface, devcnt); | Fixes: 38f8ab0bbc8d ("vhost: make vDPA framework bus agnostic") Cc: maxime.coquelin@redhat.com Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger Acked-by: Bruce Richardson --- examples/vdpa/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/vdpa/main.c b/examples/vdpa/main.c index 289db26498..08aa933272 100644 --- a/examples/vdpa/main.c +++ b/examples/vdpa/main.c @@ -22,6 +22,7 @@ #define MAX_PATH_LEN 128 #define MAX_VDPA_SAMPLE_PORTS 1024 +#define MAX_VDPA_STR_LEN sizeof(RTE_STR(MAX_VDPA_SAMPLE_PORTS)) #define RTE_LOGTYPE_VDPA RTE_LOGTYPE_USER1 struct vdpa_port { @@ -36,7 +37,7 @@ struct vdpa_port { static struct vdpa_port vports[MAX_VDPA_SAMPLE_PORTS]; -static char iface[MAX_PATH_LEN]; +static char iface[MAX_PATH_LEN - MAX_VDPA_STR_LEN]; static int devcnt; static int interactive; static int client_mode; @@ -74,9 +75,8 @@ parse_args(int argc, char **argv) break; /* long options */ case 0: - if (strncmp(long_option[idx].name, "iface", - MAX_PATH_LEN) == 0) { - rte_strscpy(iface, optarg, MAX_PATH_LEN); + if (!strcmp(long_option[idx].name, "iface")) { + rte_strscpy(iface, optarg, sizeof(iface)); printf("iface %s\n", iface); } if (!strcmp(long_option[idx].name, "interactive")) { -- 2.51.0