[PATCH i-g-t 2/2] intel_bios_reader: Don't explode looking for the devid

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx>

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@xxxxxxxxxxxxxxx>
---
 tools/intel_bios_reader.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tools/intel_bios_reader.c b/tools/intel_bios_reader.c
index 641cb38..c5fc777 100644
--- a/tools/intel_bios_reader.c
+++ b/tools/intel_bios_reader.c
@@ -1052,11 +1052,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' ||
@@ -1296,7 +1299,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");
 
-- 
2.0.5

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx





[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux