]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
libkmod: Properly skip first symbol entry
authorTobias Stoeckmann <tobias@stoeckmann.org>
Tue, 29 Oct 2024 16:45:01 +0000 (17:45 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Wed, 30 Oct 2024 12:59:18 +0000 (07:59 -0500)
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 <emil.l.velikov@gmail.com>
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/215
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
libkmod/libkmod-elf.c

index 956000fc119efb4ca40fd82c16b387a2deb8ba10..0a23f9180414717e70a80995cf84e6eba053f118 100644 (file)
@@ -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;