1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-26 22:52:34 +02:00

dmi.c: Duplicate returned strings because they are meant to be freed

Without this patch dmi_shutdown calls free() on read-only strings.

Corresponding to flashrom svn r1849.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
This commit is contained in:
Stefan Tauner 2014-09-05 16:14:11 +00:00
parent 2a1ed77f84
commit 778c6d81c8

6
dmi.c
View File

@ -120,18 +120,18 @@ static char *dmi_string(const char *buf, uint8_t string_id, const char *limit)
size_t i, len;
if (string_id == 0)
return "Not Specified";
return strdup("Not Specified");
while (string_id > 1 && string_id--) {
if (buf >= limit) {
msg_perr("DMI table is broken (string portion out of bounds)!\n");
return "<OUT OF BOUNDS>";
return strdup("<OUT OF BOUNDS>");
}
buf += strnlen(buf, limit - buf) + 1;
}
if (!*buf) /* as long as the current byte we're on isn't null */
return "<BAD INDEX>";
return strdup("<BAD INDEX>");
len = strnlen(buf, limit - buf);
char *newbuf = malloc(len + 1);