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 82354A0C4C for ; Tue, 23 Nov 2021 10:00:25 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 777EA410E4; Tue, 23 Nov 2021 10:00:25 +0100 (CET) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2084.outbound.protection.outlook.com [40.107.220.84]) by mails.dpdk.org (Postfix) with ESMTP id F122E4003C; Tue, 23 Nov 2021 10:00:23 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Eg0PE1qGnq1N57REaYUCWeVk9uJ5WTgQibmkYm+aiKBK+WLLVqLKBa/YiSokhHLX6b3uU+qtKrx0u67+iItTeEQhb2IHLl65FzOCIBUstsB9JDYEkRpYinrjdU9+HfWjqx/ihI4JyuKsClxd1n+1dp4l8MKQe16N13k68JGMfxPZPEtx/0H1m8XVmqjN805SUY/lk0Qz5+kGs1TjmvdZGSzXxhfDLvJgb6bhTME01N3keVAGUcmGMwgrBjpIxTXWBlIX4/jRh54Uvi4gLdxO1dF+gyfA3fytjlqIMI4nrB4/Az4M+W/tMIvl/bVOom/fvQdeJ75TCuQBUNVtGc9+qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ZsCJhdHwQS1PN7/VpLINeXxARA7aKKf1VUJBJlqNRSA=; b=izM6wKh7vNfjwONBtsCEbb1fKcimCNTrJoNRu0fzMcoVonezw+MTq+RVicSYf0U2oT6OoTIJuYrTAKpdXq0WBDgMTM9laAhxa/6+soiDQcBF22iGHGdH1ZjcbPDvjqC+rnMZ0zO57qc+5VLjOTcOnxBFhI0E+8N7B+xjI5qqFdh4tS/YYrS17TaX80OCJCSXHNwcxGROaxuEw7Mh1EMmCLUU0eLbHQoUv2jbgyPNRWQAZt4dsJvyyDfDzxfhicwRorrK8+UJ+oO65tYoXKdq8rLcrgeeddKjvS95AxzBNfxuE3Uu2cBqQdaBgl9IsmQKxO0mFlPkBHWfTswaT7k9Vg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=intel.com smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZsCJhdHwQS1PN7/VpLINeXxARA7aKKf1VUJBJlqNRSA=; b=VpM7Tw0XRt23UJq6lugSthdaoPXiKm4sU3Tc5lwRsVR3XNDqDCuQSkXRpmd6rewMjrx3sNBQIy1SfZQlMeWM1UkqZaRqLzyqM4ZAqI9PRrCxQHZd0HJdCy3wkA9VN5MwTKqDeYtc6B6H5D3GDLS4jhSgrxV6SRrc6Z3wSCJbdSKx3Yk+m6V+eWaMnc1xmk7HfDbX1L38mALRzUlFrNKwFdBPYOoIatDVeNw4AqvxdZMYqE1A0p04NPcX88I6wOpSFn5YuVEg/QepxId92JR79PnVywMKc6ZwyjsZe1UiwqxNmE/Znc418Aj1e8vxr9byNazFDIoeMXo27M32M184zg== Received: from MWHPR21CA0068.namprd21.prod.outlook.com (2603:10b6:300:db::30) by CY4PR12MB1575.namprd12.prod.outlook.com (2603:10b6:910:f::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.20; Tue, 23 Nov 2021 09:00:21 +0000 Received: from CO1NAM11FT009.eop-nam11.prod.protection.outlook.com (2603:10b6:300:db:cafe::e0) by MWHPR21CA0068.outlook.office365.com (2603:10b6:300:db::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4755.4 via Frontend Transport; Tue, 23 Nov 2021 09:00:21 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by CO1NAM11FT009.mail.protection.outlook.com (10.13.175.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4713.20 via Frontend Transport; Tue, 23 Nov 2021 09:00:21 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 23 Nov 2021 09:00:18 +0000 From: Gregory Etelson To: , CC: , Ferruh Yigit , , Ori Kam , Xiaoyun Li , Wei Zhao Subject: [PATCH] app/testpmd: fix hex string parser input length Date: Tue, 23 Nov 2021 11:00:05 +0200 Message-ID: <20211123090005.24707-1-getelson@nvidia.com> X-Mailer: git-send-email 2.34.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7d8a79b4-1236-439f-9195-08d9ae5fae09 X-MS-TrafficTypeDiagnostic: CY4PR12MB1575: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:197; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uaR+kZwCV3NoNOpcQ0+mBby4FkaYHEGpJr0O9zD/6HZ5u2AeIeqN+B5KBUBnQ7H9iPreL/A3WdZvy28BMwD5UoaFvRZoKIJ2TaX+kPf/vBnkhMGGANUMbdtAnwJkM7HmYnc5rIpJ4D6h/y0JRr4pSAPzcDNtZD87cT7hANe61rO0e1jY9X70ERru6DmKxT1wPfZd6G94XIOgCzEiAhW3GY4gY2WMU5Q5N0QYfmvJeQWVxm1MatDfPjLe5lM/uFOGy/t1IC/nolIrjfA2wgAdMbXC3VA/9G9EaYp+DKlyWt3eYnbxXXmzr8B6YO8NlVfK9EoR4iIFveWoWDeW5G91jUzLuD4aEPt5VxzzkDcP2/HTPukUG1wJpH8F5LsDcapif8k3zq4PjHtqYsRBATfZrXzJ2bUvKwVfUXN+w35FcOaz+rH/VoLeAWyPHfolTiPxdwYXVBchkoI2N8HJByJG+GItkFGP5GCgzSmL2I7gCjXQfW2bNiYH8bDq453msvauXtrqxokSz4z75FK8yo8FDSvNu6loJ4rYtKEvLUXkBBxjJrFOUxcasfKrrsXWbPr+vb/Xb+V8HYH9qXLMbTMXHQpy5DkNFrWH8wQvsBr8k93YvEJPcOvr9UhBckImOUqihcBZv2oWogXIpmi83P1RLmzH8OfnImadK9U+kDR4+kuRlNYcQHLhiIKvC7epxTHZkneDr0aRoeyZbctlgmH+Fw== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(36756003)(36860700001)(8936002)(86362001)(336012)(508600001)(54906003)(426003)(7049001)(26005)(82310400004)(2906002)(4326008)(83380400001)(8676002)(55016003)(7696005)(1076003)(7636003)(47076005)(5660300002)(356005)(6286002)(6666004)(110136005)(2616005)(316002)(16526019)(70586007)(186003)(70206006); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2021 09:00:21.3185 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7d8a79b4-1236-439f-9195-08d9ae5fae09 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT009.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1575 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 Current hex string parser assumes input has even characters number. The parser fails input string with odd length. The patch parses hex stringhs with even and odd length. Cc: stable@dpdk.org Fixes: 169a9fed1f4c ("app/testpmd: fix hex string parser support for flow API") Signed-off-by: Gregory Etelson --- app/test-pmd/cmdline_flow.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 1b00ae507b..2b90a4a23a 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -7702,9 +7702,7 @@ parse_string(struct context *ctx, const struct token *token, static int parse_hex_string(const char *src, uint8_t *dst, uint32_t *size) { - char *c = NULL; - uint32_t i, len; - char tmp[3]; + uint32_t left = *size; /* Check input parameters */ if ((src == NULL) || @@ -7714,19 +7712,21 @@ parse_hex_string(const char *src, uint8_t *dst, uint32_t *size) return -1; /* Convert chars to bytes */ - for (i = 0, len = 0; i < *size; i += 2) { - snprintf(tmp, 3, "%s", src + i); - dst[len++] = strtoul(tmp, &c, 16); - if (*c != 0) { - len--; - dst[len] = 0; - *size = len; - return -1; + while (left) { + char tmp[3], *end = tmp; + uint32_t read_lim = left & 1 ? 1 : 2; + + snprintf(tmp, read_lim + 1, "%s", src); + *dst = strtoul(tmp, &end, 16); + if (*end) { + *dst = 0; + *size = *size - left; } + left -= read_lim; + src += read_lim; + dst++; } - dst[len] = 0; - *size = len; - + *dst = 0; return 0; } -- 2.34.0