summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhailfinger <hailfinger@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2016-03-13 17:36:49 +0000
committerhailfinger <hailfinger@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2016-03-13 17:36:49 +0000
commit29f941e34098f26b1cfb1c8de6902aa87c52713a (patch)
tree256397cb2fdd75f385eae063502253f1985956ae
parentea134dce722556475293ec47fbea97bc65a296cd (diff)
downloadflashrom-29f941e34098f26b1cfb1c8de6902aa87c52713a.tar.gz
Fix fscanf format string security bug in layout.c
An internal security audit of the flashrom project by Carl-Daniel Hailfinger found a buffer overflow bug present in all flashrom versions since the year 2005. This bug was independently found and reported to flashrom.org by Cosmin Gorgovan a few days ago. A buffer on the stack and a buffer on the heap are affected by the overflow caused by an incorrect fscanf format string. The buffer overflow can only be triggered if the optional layout feature is used and if the user manually specifies a specially crafted layout file on the command line. Command line parsing and flash image handling do not trigger the buggy code path. Most usage of flashrom does not involve layout files. The fix in this commit (changed fscanf format string) can be applied to layout.c of all past flashrom versions. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@1953 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
-rw-r--r--layout.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/layout.c b/layout.c
index d039451..f71eeaa 100644
--- a/layout.c
+++ b/layout.c
@@ -68,7 +68,7 @@ int read_romlayout(const char *name)
(void)fclose(romlayout);
return 1;
}
- if (2 != fscanf(romlayout, "%s %s\n", tempstr, rom_entries[num_rom_entries].name))
+ if (2 != fscanf(romlayout, "%255s %255s\n", tempstr, rom_entries[num_rom_entries].name))
continue;
#if 0
// fscanf does not like arbitrary comments like that :( later