summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/dmidecode/dmidecode/CVE-2023-30630_1b.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/dmidecode/dmidecode/CVE-2023-30630_1b.patch')
-rw-r--r--meta/recipes-devtools/dmidecode/dmidecode/CVE-2023-30630_1b.patch197
1 files changed, 197 insertions, 0 deletions
diff --git a/meta/recipes-devtools/dmidecode/dmidecode/CVE-2023-30630_1b.patch b/meta/recipes-devtools/dmidecode/dmidecode/CVE-2023-30630_1b.patch
new file mode 100644
index 0000000000..e03bda05e4
--- /dev/null
+++ b/meta/recipes-devtools/dmidecode/dmidecode/CVE-2023-30630_1b.patch
@@ -0,0 +1,197 @@
1From d362549bce92ac22860cda8cad4532c1a3fe6928 Mon Sep 17 00:00:00 2001
2From: Jean Delvare <jdelvare@suse.de>
3Date: Mon, 20 Feb 2023 14:53:25 +0100
4Subject: [PATCH 2/5] dmidecode: Write the whole dump file at once
5
6When option --dump-bin is used, write the whole dump file at once,
7instead of opening and closing the file separately for the table
8and then for the entry point.
9
10As the file writing function is no longer generic, it gets moved
11from util.c to dmidecode.c.
12
13One minor functional change resulting from the new implementation is
14that the entry point is written first now, so the messages printed
15are swapped.
16
17Signed-off-by: Jean Delvare <jdelvare@suse.de>
18Reviewed-by: Jerry Hoemann <jerry.hoemann@hpe.com>
19
20CVE: CVE-2023-30630
21
22Upstream-Status: Backport [https://git.savannah.nongnu.org/cgit/dmidecode.git/commit/?id=d8cfbc808f387e87091c25e7d5b8c2bb348bb206]
23
24Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
25---
26 dmidecode.c | 69 +++++++++++++++++++++++++++++++++++++++--------------
27 util.c | 40 -------------------------------
28 util.h | 1 -
29 3 files changed, 51 insertions(+), 59 deletions(-)
30
31diff --git a/dmidecode.c b/dmidecode.c
32index b082c03..a80a140 100644
33--- a/dmidecode.c
34+++ b/dmidecode.c
35@@ -5130,11 +5130,56 @@ static void dmi_table_string(const struct dmi_header *h, const u8 *data, u16 ver
36 }
37 }
38
39-static void dmi_table_dump(const u8 *buf, u32 len)
40+static int dmi_table_dump(const u8 *ep, u32 ep_len, const u8 *table,
41+ u32 table_len)
42 {
43+ FILE *f;
44+
45+ f = fopen(opt.dumpfile, "wb");
46+ if (!f)
47+ {
48+ fprintf(stderr, "%s: ", opt.dumpfile);
49+ perror("fopen");
50+ return -1;
51+ }
52+
53+ if (!(opt.flags & FLAG_QUIET))
54+ pr_comment("Writing %d bytes to %s.", ep_len, opt.dumpfile);
55+ if (fwrite(ep, ep_len, 1, f) != 1)
56+ {
57+ fprintf(stderr, "%s: ", opt.dumpfile);
58+ perror("fwrite");
59+ goto err_close;
60+ }
61+
62+ if (fseek(f, 32, SEEK_SET) != 0)
63+ {
64+ fprintf(stderr, "%s: ", opt.dumpfile);
65+ perror("fseek");
66+ goto err_close;
67+ }
68+
69 if (!(opt.flags & FLAG_QUIET))
70- pr_comment("Writing %d bytes to %s.", len, opt.dumpfile);
71- write_dump(32, len, buf, opt.dumpfile, 0);
72+ pr_comment("Writing %d bytes to %s.", table_len, opt.dumpfile);
73+ if (fwrite(table, table_len, 1, f) != 1)
74+ {
75+ fprintf(stderr, "%s: ", opt.dumpfile);
76+ perror("fwrite");
77+ goto err_close;
78+ }
79+
80+ if (fclose(f))
81+ {
82+ fprintf(stderr, "%s: ", opt.dumpfile);
83+ perror("fclose");
84+ return -1;
85+ }
86+
87+ return 0;
88+
89+err_close:
90+ fclose(f);
91+ return -1;
92 }
93
94 static void dmi_table_decode(u8 *buf, u32 len, u16 num, u16 ver, u32 flags)
95@@ -5387,11 +5432,7 @@ static int smbios3_decode(u8 *buf, const char *devmem, u32 flags)
96 memcpy(crafted, buf, 32);
97 overwrite_smbios3_address(crafted);
98
99- dmi_table_dump(table, len);
100- if (!(opt.flags & FLAG_QUIET))
101- pr_comment("Writing %d bytes to %s.", crafted[0x06],
102- opt.dumpfile);
103- write_dump(0, crafted[0x06], crafted, opt.dumpfile, 1);
104+ dmi_table_dump(crafted, crafted[0x06], table, len);
105 }
106 else
107 {
108@@ -5463,11 +5504,7 @@ static int smbios_decode(u8 *buf, const char *devmem, u32 flags)
109 memcpy(crafted, buf, 32);
110 overwrite_dmi_address(crafted + 0x10);
111
112- dmi_table_dump(table, len);
113- if (!(opt.flags & FLAG_QUIET))
114- pr_comment("Writing %d bytes to %s.", crafted[0x05],
115- opt.dumpfile);
116- write_dump(0, crafted[0x05], crafted, opt.dumpfile, 1);
117+ dmi_table_dump(crafted, crafted[0x05], table, len);
118 }
119 else
120 {
121@@ -5508,11 +5545,7 @@ static int legacy_decode(u8 *buf, const char *devmem, u32 flags)
122 memcpy(crafted, buf, 16);
123 overwrite_dmi_address(crafted);
124
125- dmi_table_dump(table, len);
126- if (!(opt.flags & FLAG_QUIET))
127- pr_comment("Writing %d bytes to %s.", 0x0F,
128- opt.dumpfile);
129- write_dump(0, 0x0F, crafted, opt.dumpfile, 1);
130+ dmi_table_dump(crafted, 0x0F, table, len);
131 }
132 else
133 {
134diff --git a/util.c b/util.c
135index 04aaadd..1547096 100644
136--- a/util.c
137+++ b/util.c
138@@ -259,46 +259,6 @@ out:
139 return p;
140 }
141
142-int write_dump(size_t base, size_t len, const void *data, const char *dumpfile, int add)
143-{
144- FILE *f;
145-
146- f = fopen(dumpfile, add ? "r+b" : "wb");
147- if (!f)
148- {
149- fprintf(stderr, "%s: ", dumpfile);
150- perror("fopen");
151- return -1;
152- }
153-
154- if (fseek(f, base, SEEK_SET) != 0)
155- {
156- fprintf(stderr, "%s: ", dumpfile);
157- perror("fseek");
158- goto err_close;
159- }
160-
161- if (fwrite(data, len, 1, f) != 1)
162- {
163- fprintf(stderr, "%s: ", dumpfile);
164- perror("fwrite");
165- goto err_close;
166- }
167-
168- if (fclose(f))
169- {
170- fprintf(stderr, "%s: ", dumpfile);
171- perror("fclose");
172- return -1;
173- }
174-
175- return 0;
176-
177-err_close:
178- fclose(f);
179- return -1;
180-}
181-
182 /* Returns end - start + 1, assuming start < end */
183 u64 u64_range(u64 start, u64 end)
184 {
185diff --git a/util.h b/util.h
186index 3094cf8..ef24eb9 100644
187--- a/util.h
188+++ b/util.h
189@@ -27,5 +27,4 @@
190 int checksum(const u8 *buf, size_t len);
191 void *read_file(off_t base, size_t *len, const char *filename);
192 void *mem_chunk(off_t base, size_t len, const char *devmem);
193-int write_dump(size_t base, size_t len, const void *data, const char *dumpfile, int add);
194 u64 u64_range(u64 start, u64 end);
195--
1962.41.0
197