From 0c7cac3be12707225d03888a6047e5133d926751 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Wed, 16 Sep 2020 15:11:17 +0100 Subject: [PATCH] Problem: uninitialized memory access in zarmour_test Solution: check for size == 0 before dereferencing data pointers --- src/zarmour.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/zarmour.c b/src/zarmour.c index 2860f975c7d9ef6d4b25330a4b0867fa528c37a4..273eb54cf47c1942a530efc04dbf782af2fae82b 100644 --- a/src/zarmour.c +++ b/src/zarmour.c @@ -657,8 +657,8 @@ s_armour_decode (zarmour_t *self, const char *test_string, const char *expected, zsys_debug (" decoded '%s' into '%s'", test_string, (char *) zchunk_data (chunk)); assert (zchunk_size (chunk) == strlen (expected) + 1 || (strlen (expected) == 0 && zchunk_size (chunk) == 0)); - assert (streq ((char *) zchunk_data (chunk), expected) - || (strlen (expected) == 0 && zchunk_size (chunk) == 0)); + assert ((strlen (expected) == 0 && zchunk_size (chunk) == 0) + || streq ((char *) zchunk_data (chunk), expected)); zchunk_destroy (&chunk); }