]> git.droids-corp.org - dpdk.git/commitdiff
test/mbuf: fix mbuf data content check
authorDavid Marchand <david.marchand@redhat.com>
Thu, 3 Feb 2022 09:39:12 +0000 (10:39 +0100)
committerDavid Marchand <david.marchand@redhat.com>
Fri, 11 Feb 2022 07:50:13 +0000 (08:50 +0100)
When allocating a mbuf, its data content is most of the time zero'd but
nothing ensures this. This is especially wrong when building with
RTE_MALLOC_DEBUG, where data is poisoned to 0x6b on free.

This test reserves MBUF_TEST_DATA_LEN2 bytes in the mbuf data segment,
and sets this data to 0xcc.
Calling strlen(), the test may try to read more than MBUF_TEST_DATA_LEN2
which has been noticed when memory had been poisoned.

The mbuf data content is checked right after, so we can simply remove
strlen().

Fixes: 7b295dceea07 ("test/mbuf: add unit test cases")
Cc: stable@dpdk.org
Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
app/test/test_mbuf.c

index f762befb695492237c19319cbea3111007a2cc0b..d37aefd2e969687a75c4e5d3314f2f8a413f3273 100644 (file)
@@ -2042,8 +2042,6 @@ test_pktmbuf_read_from_offset(struct rte_mempool *pktmbuf_pool)
                        NULL);
        if (data_copy == NULL)
                GOTO_FAIL("%s: Error in reading packet data!\n", __func__);
-       if (strlen(data_copy) != MBUF_TEST_DATA_LEN2 - 5)
-               GOTO_FAIL("%s: Incorrect data length!\n", __func__);
        for (off = 0; off < MBUF_TEST_DATA_LEN2 - 5; off++) {
                if (data_copy[off] != (char)0xcc)
                        GOTO_FAIL("Data corrupted at offset %u", off);
@@ -2065,8 +2063,6 @@ test_pktmbuf_read_from_offset(struct rte_mempool *pktmbuf_pool)
        data_copy = rte_pktmbuf_read(m, hdr_len, 0, NULL);
        if (data_copy == NULL)
                GOTO_FAIL("%s: Error in reading packet data!\n", __func__);
-       if (strlen(data_copy) != MBUF_TEST_DATA_LEN2)
-               GOTO_FAIL("%s: Corrupted data content!\n", __func__);
        for (off = 0; off < MBUF_TEST_DATA_LEN2; off++) {
                if (data_copy[off] != (char)0xcc)
                        GOTO_FAIL("Data corrupted at offset %u", off);