From c8af73112027fad0ecbb277e9cba257678c405af Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Wed, 7 Dec 2022 10:23:46 -0800 Subject: [PATCH] outieee: fix segfault on empty input Fix the IEEE backend crashing if the input file is empty. Signed-off-by: H. Peter Anvin Upstream-Status: Backport [https://github.com/netwide-assembler/nasm/commit/c8af73112027fad0ecbb277e9cba257678c405af] CVE: CVE-2022-46457 Signed-off-by: Archana Polampalli --- output/outieee.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/output/outieee.c b/output/outieee.c index cdb8333..8bc5eaa 100644 --- a/output/outieee.c +++ b/output/outieee.c @@ -919,7 +919,7 @@ static void ieee_write_file(void) * Write the section headers */ seg = seghead; - if (!debuginfo && !strcmp(seg->name, "??LINE")) + if (!debuginfo && seg && !strcmp(seg->name, "??LINE")) seg = seg->next; while (seg) { char buf[256]; @@ -954,7 +954,7 @@ static void ieee_write_file(void) /* * write the start address if there is one */ - if (ieee_entry_seg) { + if (ieee_entry_seg && seghead) { for (seg = seghead; seg; seg = seg->next) if (seg->index == ieee_entry_seg) break; @@ -1067,7 +1067,7 @@ static void ieee_write_file(void) * put out section data; */ seg = seghead; - if (!debuginfo && !strcmp(seg->name, "??LINE")) + if (!debuginfo && seg && !strcmp(seg->name, "??LINE")) seg = seg->next; while (seg) { if (seg->currentpos) { -- 2.40.0