summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorVille Syrjälä <ville.syrjala@linux.intel.com>2015-03-25 20:23:30 +0200
committerVille Syrjälä <ville.syrjala@linux.intel.com>2015-09-11 15:58:39 +0300
commitb701bb14c6fc82edfb07c2f6087b96e36dd48efe (patch)
tree7f2a4ff0e341a573919ca6730d68f5aaad533aea /tools
parentb1e756451c59b342a9d15433379bf543ddedd56b (diff)
intel_bios_reader: Don't explode looking for the devid
Check that the offset where expect to find the device id is withing the BIOS image, instead of accessing whatever (if anything) happens to be there. Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/intel_bios_reader.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/tools/intel_bios_reader.c b/tools/intel_bios_reader.c
index a5412f5a..bb6139eb 100644
--- a/tools/intel_bios_reader.c
+++ b/tools/intel_bios_reader.c
@@ -1055,11 +1055,14 @@ err:
static int
-get_device_id(unsigned char *bios)
+get_device_id(unsigned char *bios, int size)
{
int device;
int offset = (bios[0x19] << 8) + bios[0x18];
+ if (offset + 7 >= size)
+ return -1;
+
if (bios[offset] != 'P' ||
bios[offset+1] != 'C' ||
bios[offset+2] != 'I' ||
@@ -1299,7 +1302,7 @@ int main(int argc, char **argv)
printf("\n");
if (devid == -1)
- devid = get_device_id(VBIOS);
+ devid = get_device_id(VBIOS, size);
if (devid == -1)
printf("Warning: could not find PCI device ID!\n");