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 08B8AA0547; Fri, 10 Sep 2021 16:16:50 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6235841157; Fri, 10 Sep 2021 16:16:46 +0200 (CEST) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2053.outbound.protection.outlook.com [40.107.94.53]) by mails.dpdk.org (Postfix) with ESMTP id EA24741160; Fri, 10 Sep 2021 16:16:44 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UcMcPHLLoRwWjAbQcyBwyqZm8PEwXk3urd/oB5rMTk82UCerONCquJKpKEgdwZRuOQ1RsbNKexHeewsYLzFOccyFiLCBBOd8jnlptcYNV+LuQ0dm9i0kEGa5ue1nmEck5NphEud6cdbkotemQ9v5ITtUU+s3gYVP8ZFsI/2A5eROtu3BByLHWmsCj/ZWcT9JmR5pD5QxBwXgCb0GnnX1PXUQ8n5kQ6nFQZdgKQDedEyM63HyNIJt75hOWYCGCqBN5rbMMIKENN1xCm5IEVprLKe2C6mKjH2xVsIH/J8bI9sgsYbV9dMzQVGK19VcCQU6HRRjT9lSFnLI3vFU3LcyJw== 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; bh=aZ6V/GmkdQoXsOHTmfhUatN7JYWUFcVXnH7s612b7wU=; b=PNZwy9LI/ooZgaV3aJaENIiEBf01cKjQuKn14AyNRKlLCuk8Z7UIar7ZfVVp/0q8AGgMYpByeYWfBv3opBaVXafHy3cV9X4JKBU4VeSNScrmdRBu6dCMpejk0EXTybhY8VcIMj3/+x9m4FW5F6yFz2UCvi/48xIHvIrPngWVtiATy3qnzwtlkEAM+WJEIdK+S75XyRme5Pjj14HFbCF25++TvWLo0dJR4cz/yW6sUGU5vRboYdKu+/bU2g2jJUvvd67/j0McI9bo1w8XvKBP++tFgjF4apemo0qC30jasxXidkzwnJdzTYeOkAxoytqRzdJyRDcQnKVt92Ymf+ZHTA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.36) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none 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=aZ6V/GmkdQoXsOHTmfhUatN7JYWUFcVXnH7s612b7wU=; b=d4xUzIcsGovFN+KilRHIRDgOCtpv1JVkr81ySuF8L9RWvKu8BCYKQPO3l6wB6nsW7+LVDoN0XGrt9PEIUzNx3cuhiHaPV/ldNuMu0eqFzoeJqq6OwFIe+4SIZYgHc1RjCNv06gDnXwzH4r2T9dcl+z2oGNOdsEkmdEnN9CuW4jYhNk2LXujLn8wJIQECrm5VSgbagMbE9VOb37odJfR4OWtAu16TWhcboFFd1hMnRACQaH3e6/sV1ck5KffDPmP8vwO40i7r0hPgrrzLWRBJm1CgM1JArgYYpjmxcT+9zPOIqDSRTZGUkPRIscyflGY8Z8GttFpcirL8UWlrcHZaxg== Received: from MW4PR03CA0256.namprd03.prod.outlook.com (2603:10b6:303:b4::21) by MW3PR12MB4505.namprd12.prod.outlook.com (2603:10b6:303:5a::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.16; Fri, 10 Sep 2021 14:16:43 +0000 Received: from CO1NAM11FT034.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b4:cafe::3c) by MW4PR03CA0256.outlook.office365.com (2603:10b6:303:b4::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Fri, 10 Sep 2021 14:16:43 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.36) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.36 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.36; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.36) by CO1NAM11FT034.mail.protection.outlook.com (10.13.174.248) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4500.14 via Frontend Transport; Fri, 10 Sep 2021 14:16:42 +0000 Received: from DRHQMAIL107.nvidia.com (10.27.9.16) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Fri, 10 Sep 2021 14:16:42 +0000 Received: from nvidia.com (172.20.187.5) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Fri, 10 Sep 2021 14:16:41 +0000 From: Viacheslav Ovsiienko To: CC: , Date: Fri, 10 Sep 2021 17:16:09 +0300 Message-ID: <20210910141609.8410-3-viacheslavo@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20210910141609.8410-1-viacheslavo@nvidia.com> References: <20210910141609.8410-1-viacheslavo@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.20.187.5] X-ClientProxiedBy: HQMAIL107.nvidia.com (172.20.187.13) To DRHQMAIL107.nvidia.com (10.27.9.16) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 231c6d12-4744-4aae-abfb-08d974659d63 X-MS-TrafficTypeDiagnostic: MW3PR12MB4505: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2803; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kpmT1EFgyHorHVzwmVGxcQe9hnL++vgj4VBUkzsVbeayjDDUWQEVZYJSKWbjHOH3M+3LkOSPkxvw60vNCFvIzTzDfOXfdOzML51QNwdxPMUP3mfCGBLYh5H9Jr3tWs2mZ87CdROhs22gyB2XP198E0PuGJlwqm0s0TOcq8QBJDWdv/sMxS1WKeklq/K8/LAV9BTSyVI0GLCo1MiRajAx+qpCVCsuoHOttnlYMUm17Jev/a8gbOeYxdsbnApABSaFRrQAGwX3BHtQkUQDAOxUaD9Qx9LRlX1QrNLeO7YqCUMKPns+1BM+gfginSDR9KfpY2hjxFxwvBPmR21jG1ipdJgWKuFE55MxJZuA5q7eoSL3plVtR1EqQA57BJRrhYVVENW8mIzGayISfw6XUJ/51gShDYmFV/YGV3yQDQP5c6v12QN1AmJLSPxuwrmPqorMxeRF5qU4UVJ43swvJD0iNFev+DeiazeTs+ftz5qUHD9zX8JWk/5MkyBIxHmB3tFJ6ZPolFCVnAcX+yEPyn3z9Rfa4UxEZbdHbBm4hITeN+IUQHL6WgVJpKP+7GWqja9cR1xiWLi4Jx1X1jcxqmusdrK13mQW46kH2ThdjCkA88WZCmTbxiGZemYCetAOlD9d9dhm9Jake/z9o1rRwFw+XvePff1CMv3Se0ZjHxEjQmXMfLdKWmANuffZqnvR+vZRkFFX5ydxzMORPRK/szeMcw== X-Forefront-Antispam-Report: CIP:216.228.112.36; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid05.nvidia.com; CAT:NONE; SFS:(4636009)(136003)(396003)(39860400002)(346002)(376002)(46966006)(36840700001)(6286002)(7636003)(6916009)(86362001)(70206006)(55016002)(478600001)(82740400003)(8936002)(7696005)(82310400003)(36860700001)(356005)(47076005)(4326008)(26005)(426003)(16526019)(186003)(36906005)(36756003)(336012)(2616005)(2906002)(1076003)(450100002)(8676002)(5660300002)(70586007)(54906003)(6666004)(316002)(83380400001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2021 14:16:42.9721 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 231c6d12-4744-4aae-abfb-08d974659d63 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.36]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT034.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4505 Subject: [dpdk-dev] [RFC 3/3] app/testpmd: fix hex string parser in flow commands X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" The hexadecimal string parser does not check the target field buffer size, buffer overflow happens and might cause the application failure (segmentation fault is observed usually). Fixes: 169a9fed1f4c ("app/testpmd: fix hex string parser support for flow API") Cc: stable@dpdk.org Signed-off-by: Viacheslav Ovsiienko --- app/test-pmd/cmdline_flow.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 529ead6b2a..9e7fe1ae9f 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -7291,10 +7291,13 @@ parse_hex(struct context *ctx, const struct token *token, hexlen -= 2; } if (hexlen > length) - return -1; + goto error; ret = parse_hex_string(str, hex_tmp, &hexlen); if (ret < 0) goto error; + /* Check the converted binary fits into data buffer. */ + if (hexlen > size) + goto error; /* Let parse_int() fill length information first. */ ret = snprintf(tmp, sizeof(tmp), "%u", hexlen); if (ret < 0) -- 2.18.1