amd/common: fix off-by-one in sid_tables.py
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Tue, 6 Jun 2017 17:17:49 +0000 (19:17 +0200)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Mon, 19 Jun 2017 10:03:59 +0000 (12:03 +0200)
The very last entry in the sid_strings_offsets table ended up missing,
leading to out-of-bounds reads and potential crashes.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/amd/common/sid_tables.py

index fd88d3c9d5ddc06ba90a1d771fe86a8c5330496f..0a2b7ef1fe4cc3c15acdd69c3d8f15293d73af7f 100644 (file)
@@ -110,7 +110,7 @@ class IntTable:
         [static] const typename name[] = { ... };
         to filp.
         """
-        idxs = sorted(self.idxs) + [-1]
+        idxs = sorted(self.idxs) + [len(self.table)]
 
         fragments = [
             ('\t/* %s */ %s' % (