libkmod: use helper function to check for overflow
authorLucas De Marchi <lucas.demarchi@intel.com>
Tue, 10 Feb 2015 12:46:26 +0000 (10:46 -0200)
committerLucas De Marchi <lucas.demarchi@intel.com>
Tue, 10 Feb 2015 12:46:26 +0000 (10:46 -0200)
libkmod/libkmod-elf.c

index 8a8a73d..4af829e 100644 (file)
@@ -250,8 +250,8 @@ static inline int elf_get_section_info(const struct kmod_elf *elf, uint16_t idx,
        }
 #undef READV
 
-       min_size = *offset + *size;
-       if (ULLONG_MAX - *offset < *size || min_size > elf->size) {
+       if (addu64_overflow(*offset, *size, &min_size)
+           || min_size > elf->size) {
                ELFDBG(elf, "out-of-bounds: %"PRIu64" >= %"PRIu64" (ELF size)\n",
                       min_size, elf->size);
                return -EINVAL;