]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
libkmod: Add another section size check
authorTobias Stoeckmann <tobias@stoeckmann.org>
Tue, 15 Oct 2024 16:19:32 +0000 (18:19 +0200)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Thu, 17 Oct 2024 21:47:03 +0000 (16:47 -0500)
Make sure that section is actually large enough to hold a 32 bit value.

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/181
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
libkmod/libkmod-elf.c

index 3e97aaa25bd83d1f1aee0e4bde54cef1519a4d06..d381e36504de08bc7c696efe03695fe6cb48c1e9 100644 (file)
@@ -781,7 +781,7 @@ static uint64_t kmod_elf_resolve_crc(const struct kmod_elf *elf, uint64_t crc,
                return (uint64_t)-1;
        }
 
-       if (crc > (size - sizeof(uint32_t))) {
+       if (size < sizeof(uint32_t) || crc > (size - sizeof(uint32_t))) {
                ELFDBG(elf,
                       "CRC offset %" PRIu64 " is too big, section %" PRIu16
                       " size is %" PRIu64 "\n",