From 1e3c272d75363c03ec5d69e66a399cdf6fc202fb Mon Sep 17 00:00:00 2001 From: Enno Boland Date: Sun, 2 Jun 2024 17:10:12 +0200 Subject: [PATCH 1/2] test: add fuzzer crash from a run on arm --- ...crash-148c92a263a7778ab27cc68ddfe0bd5c1880bb80 | Bin 0 -> 259 bytes test/fuzzer/meson.build | 1 + 2 files changed, 1 insertion(+) create mode 100644 test/fuzzer/crash-148c92a263a7778ab27cc68ddfe0bd5c1880bb80 diff --git a/test/fuzzer/crash-148c92a263a7778ab27cc68ddfe0bd5c1880bb80 b/test/fuzzer/crash-148c92a263a7778ab27cc68ddfe0bd5c1880bb80 new file mode 100644 index 0000000000000000000000000000000000000000..df5ed3160eed45c0671506b9049dffe65609865d GIT binary patch literal 259 zcmc~OE-YqZU|>*xo0!5Nz`(%Bz~I2hz{6nA$jHC~6juOZ5MTyMfWU7c76Ib_5TKU| z5(I+f5Q^b4lzt1PEiDZ!xf~jp7?ywy5CaN>tdj;}W+0Ym02u|c_AQ74I|C#S0!;sa z>WmQTKyCv&5JUk@VP;6n%t^IrNC5L07+7JF2cZHG8$i0iIx~tH7;b|+r2rFwr~?3p C+aRp~ literal 0 HcmV?d00001 diff --git a/test/fuzzer/meson.build b/test/fuzzer/meson.build index 0af5c7b4..03d11426 100644 --- a/test/fuzzer/meson.build +++ b/test/fuzzer/meson.build @@ -1,4 +1,5 @@ fuzzer_repro = files( + 'crash-148c92a263a7778ab27cc68ddfe0bd5c1880bb80', 'crash-cabfb77fc6783dc1021720ca328e923aa2cc834b', 'crash_0c006fc7bbbab8ba82abca1f01cc1f95714aaf98', 'crash_0f300b1e2028a520e74e06b9d598b97d15b34062', From 09b957968bfd73b1807c01cc48e330cd060a249d Mon Sep 17 00:00:00 2001 From: Enno Boland Date: Sun, 2 Jun 2024 17:50:56 +0200 Subject: [PATCH 2/2] traversal: push element to the stack as soon as possible This makes sure the stack element is always cleaned up, especially when push_stack fails later on. --- libsqsh/src/tree/traversal.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libsqsh/src/tree/traversal.c b/libsqsh/src/tree/traversal.c index 922c2926..70076821 100644 --- a/libsqsh/src/tree/traversal.c +++ b/libsqsh/src/tree/traversal.c @@ -75,6 +75,8 @@ push_stack(struct SqshTreeTraversal *traversal) { rv = -SQSH_ERROR_MALLOC_FAILED; goto out; } + element->next = traversal->stack; + traversal->stack = element; struct SqshArchive *archive = traversal->base_file->archive; const uint32_t dir_inode = sqsh_file_inode(traversal->current_file); @@ -88,9 +90,6 @@ push_stack(struct SqshTreeTraversal *traversal) { if (rv < 0) { goto out; } - element->next = traversal->stack; - traversal->stack = element; - traversal->current_file = &element->file; traversal->state = SQSH_TREE_TRAVERSAL_STATE_DIRECTORY_BEGIN; out: