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 93C13A00E6 for ; Wed, 10 Jul 2019 20:33:48 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A4F023195; Wed, 10 Jul 2019 20:33:47 +0200 (CEST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 568A8A3 for ; Wed, 10 Jul 2019 20:33:46 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BD8AE30F1BC0; Wed, 10 Jul 2019 18:33:44 +0000 (UTC) Received: from dhcp-25.97.bos.redhat.com (unknown [10.18.25.208]) by smtp.corp.redhat.com (Postfix) with ESMTP id D1B661001B02; Wed, 10 Jul 2019 18:33:43 +0000 (UTC) From: Aaron Conole To: dev@dpdk.org Cc: Olivier Matz , Stephen Hemminger , Andrew Rybchenko , Ferruh Yigit Date: Wed, 10 Jul 2019 14:33:42 -0400 Message-Id: <20190710183342.6459-1-aconole@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Wed, 10 Jul 2019 18:33:45 +0000 (UTC) Subject: [dpdk-dev] [PATCH] rte_ether: force format string for unformat_addr 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" rte_ether_unformation_addr is very lax in what it accepts now, including ethernet addresses formatted ambiguously as "x:xx:x:xx:x:xx". However, previously this behavior was enforced via the my_ether_aton which would fail ambiguously formatted values. Reported-by: Michael Santana Fixes: 596d31092d32 ("net: add function to convert string to ethernet address") Signed-off-by: Aaron Conole --- lib/librte_net/rte_ether.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/librte_net/rte_ether.c b/lib/librte_net/rte_ether.c index 8d040173c..4f252b813 100644 --- a/lib/librte_net/rte_ether.c +++ b/lib/librte_net/rte_ether.c @@ -45,7 +45,8 @@ rte_ether_unformat_addr(const char *s, struct rte_ether_addr *ea) if (n == 6) { /* Standard format XX:XX:XX:XX:XX:XX */ if (o0 > UINT8_MAX || o1 > UINT8_MAX || o2 > UINT8_MAX || - o3 > UINT8_MAX || o4 > UINT8_MAX || o5 > UINT8_MAX) { + o3 > UINT8_MAX || o4 > UINT8_MAX || o5 > UINT8_MAX || + strlen(s) != RTE_ETHER_ADDR_FMT_SIZE - 1) { rte_errno = ERANGE; return -1; } @@ -58,7 +59,8 @@ rte_ether_unformat_addr(const char *s, struct rte_ether_addr *ea) ea->addr_bytes[5] = o5; } else if (n == 3) { /* Support the format XXXX:XXXX:XXXX */ - if (o0 > UINT16_MAX || o1 > UINT16_MAX || o2 > UINT16_MAX) { + if (o0 > UINT16_MAX || o1 > UINT16_MAX || o2 > UINT16_MAX || + strlen(s) != RTE_ETHER_ADDR_FMT_SIZE - 4) { rte_errno = ERANGE; return -1; } -- 2.21.0