summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/nasm/nasm/CVE-2022-46457.patch
blob: 3502d572cdbbd4f3d007d83504c3b7b77c4fd1ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
From c8af73112027fad0ecbb277e9cba257678c405af Mon Sep 17 00:00:00 2001
From: "H. Peter Anvin" <hpa@zytor.com>
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 <hpa@zytor.com>

Upstream-Status: Backport [https://github.com/netwide-assembler/nasm/commit/c8af73112027fad0ecbb277e9cba257678c405af]
CVE: CVE-2022-46457

Signed-off-by: Archana Polampalli <archana.polampalli@windriver.com>
---
 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