From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3597C31E47 for ; Sat, 15 Jun 2019 06:43:50 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id 84B7A2173C for ; Sat, 15 Jun 2019 06:43:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 84B7A2173C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6D8241D56A; Sat, 15 Jun 2019 08:43:16 +0200 (CEST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 1E3731D54C; Sat, 15 Jun 2019 08:43:13 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8C1BFA96F1; Sat, 15 Jun 2019 06:43:12 +0000 (UTC) Received: from dmarchan.remote.csb (unknown [10.40.205.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1938F61B6A; Sat, 15 Jun 2019 06:43:09 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, aconole@redhat.com, msantana@redhat.com, stable@dpdk.org, Reshma Pattan Date: Sat, 15 Jun 2019 08:42:22 +0200 Message-Id: <1560580950-16754-8-git-send-email-david.marchand@redhat.com> In-Reply-To: <1560580950-16754-1-git-send-email-david.marchand@redhat.com> References: <1559638792-8608-1-git-send-email-david.marchand@redhat.com> <1560580950-16754-1-git-send-email-david.marchand@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sat, 15 Jun 2019 06:43:12 +0000 (UTC) Subject: [dpdk-dev] [PATCH v2 07/15] test/latencystats: fix stack smashing 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" Caught in one Travis run: + ------------------------------------------------------- + + Test Suite : Latency Stats Unit Test Suite + ------------------------------------------------------- + + TestCase [ 0] : test_latency_init succeeded + TestCase [ 1] : test_latency_update succeeded [snip] + TestCase [1601724781] : test_latencystats_get_names succeeded [snip] + Tests Failed : 1601790830 htonl(1601724781) -> "m", "a", "x", "_" htonl(1601790830) -> "n", "c", "y", "_" Looks like someone went too far. The test passes a bigger size than the array it passes along. Fixes: 1e3676a06e4c ("test/latency: add unit tests for latencystats library") Cc: stable@dpdk.org Signed-off-by: David Marchand Acked-by: Aaron Conole --- app/test/test_latencystats.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/app/test/test_latencystats.c b/app/test/test_latencystats.c index 039c508..8dd794b 100644 --- a/app/test/test_latencystats.c +++ b/app/test/test_latencystats.c @@ -69,13 +69,10 @@ static int test_latencystats_get_names(void) int ret = 0, i = 0; int size = 0; struct rte_metric_name names[NUM_STATS]; - struct rte_metric_name wrongnames[NUM_STATS - 2]; size_t m_size = sizeof(struct rte_metric_name); for (i = 0; i < NUM_STATS; i++) memset(&names[i], 0, m_size); - for (i = 0; i < NUM_STATS - 2; i++) - memset(&wrongnames[i], 0, m_size); /* Success Test: Valid names and size */ size = NUM_STATS; @@ -99,10 +96,6 @@ static int test_latencystats_get_names(void) TEST_ASSERT((ret == NUM_STATS), "Test Failed to get the metrics count," "Actual: %d Expected: %d", ret, NUM_STATS); - /* Failure Test: Invalid names (array size lesser than size) */ - size = NUM_STATS + 1; - ret = rte_latencystats_get_names(wrongnames, size); - TEST_ASSERT((ret == NUM_STATS), "Test Failed to get metrics names"); return TEST_SUCCESS; } @@ -112,13 +105,10 @@ static int test_latencystats_get(void) int ret = 0, i = 0; int size = 0; struct rte_metric_value values[NUM_STATS]; - struct rte_metric_value wrongvalues[NUM_STATS - 2]; size_t v_size = sizeof(struct rte_metric_value); for (i = 0; i < NUM_STATS; i++) memset(&values[i], 0, v_size); - for (i = 0; i < NUM_STATS - 2; i++) - memset(&wrongvalues[i], 0, v_size); /* Success Test: Valid values and valid size */ size = NUM_STATS; @@ -137,14 +127,6 @@ static int test_latencystats_get(void) TEST_ASSERT((ret == NUM_STATS), "Test Failed to get the stats count," "Actual: %d Expected: %d", ret, NUM_STATS); - /* Failure Test: Invalid values(array size lesser than size) - * and invalid size - */ - size = NUM_STATS + 2; - ret = rte_latencystats_get(wrongvalues, size); - TEST_ASSERT(ret == NUM_STATS, "Test Failed to get latency metrics" - " values"); - return TEST_SUCCESS; } -- 1.8.3.1