If an index file with INDEX_NODE_CHILDS flag contains illegal first
and last markers for children, it is possible to trigger an out of
boundary write.
Make sure that first value is not larger than last value while reading
index files.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/126
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
int first = read_char(in);
int last = read_char(in);
- if (first == EOF || last == EOF)
+ if (first == EOF || last == EOF || first > last)
goto err;
child_count = last - first + 1;
if (offset & INDEX_NODE_CHILDS) {
first = read_char_mm(&p);
last = read_char_mm(&p);
+
+ if (first > last)
+ return NULL;
+
child_count = last - first + 1;
for (i = 0; i < child_count; i++)
children[i] = read_u32_mm(&p);