From: Tobias Stoeckmann Date: Tue, 29 Oct 2024 16:45:01 +0000 (+0100) Subject: libkmod: Properly skip first symbol entry X-Git-Tag: v34~153 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6e10fd50dc02d25c0ca34c372f170a558f2e360a;p=thirdparty%2Fkmod.git libkmod: Properly skip first symbol entry This fixes a regression introduced while converting pointer to offset arithmetics. The for-loop itself starts at 1 already, so reflect this with the manually performed offset + length calculation right at the start. Closes: https://github.com/kmod-project/kmod/issues/214 Fixes: 25ab561b ("libkmod: Use ELF offsets more often") Reported-by: Emil Velikov Signed-off-by: Tobias Stoeckmann Link: https://github.com/kmod-project/kmod/pull/215 Signed-off-by: Lucas De Marchi --- diff --git a/libkmod/libkmod-elf.c b/libkmod/libkmod-elf.c index 956000fc..0a23f918 100644 --- a/libkmod/libkmod-elf.c +++ b/libkmod/libkmod-elf.c @@ -803,7 +803,7 @@ int kmod_elf_get_symbols(const struct kmod_elf *elf, struct kmod_modversion **ar count = 0; slen = 0; str_off = str_sec_off; - sym_off = sym_sec_off; + sym_off = sym_sec_off + symlen; for (i = 1; i < symcount; i++, sym_off += symlen) { const char *name; uint32_t name_off; @@ -847,7 +847,7 @@ int kmod_elf_get_symbols(const struct kmod_elf *elf, struct kmod_modversion **ar itr = (char *)(a + count); count = 0; str_off = str_sec_off; - sym_off = sym_sec_off; + sym_off = sym_sec_off + symlen; for (i = 1; i < symcount; i++, sym_off += symlen) { const char *name; uint32_t name_off;