lib: Fix potential out of bounds access in ring stop code

The subsequet code expects the read() to not have filled the entire
buffer, and yet we allow it to do so. Reduce the size passed to read()
by 1 to make the code sane.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
This commit is contained in:
Ville Syrjälä 2014-04-16 17:05:43 +03:00
parent 4aa2c102b9
commit 78e4c2b449

View File

@ -666,7 +666,7 @@ enum stop_ring_flags igt_get_stop_rings(void)
fd = igt_debugfs_open("i915_ring_stop", O_RDONLY);
igt_assert(fd >= 0);
l = read(fd, buf, sizeof(buf));
l = read(fd, buf, sizeof(buf)-1);
igt_assert(l > 0);
igt_assert(l < sizeof(buf));