]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
depmod: Actually use scratch buffer memory
authorTobias Stoeckmann <tobias@stoeckmann.org>
Mon, 30 Sep 2024 16:27:13 +0000 (18:27 +0200)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Tue, 1 Oct 2024 14:29:30 +0000 (09:29 -0500)
Accessing the backing "alias" char buffer directly works only as long as
all symbols are smaller than 1024, because otherwise the scratch buffer
allocates memory and the addresses do not match anymore.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/166
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
tools/depmod.c

index 4718f4d10dc2c606bb2cdc31aac94afdf2daf9b3..3117b78eeaf730e0946fc3c5106cd93f89003d74 100644 (file)
@@ -2330,6 +2330,7 @@ static int output_symbols_bin(struct depmod *depmod, FILE *out)
                int duplicate;
                const struct symbol *sym = v;
                size_t len;
+               char *s;
 
                if (sym->owner == NULL)
                        continue;
@@ -2340,12 +2341,12 @@ static int output_symbols_bin(struct depmod *depmod, FILE *out)
                        ret = -ENOMEM;
                        goto err_scratchbuf;
                }
-               memcpy(scratchbuf_str(&salias) + baselen, sym->name, len + 1);
-               duplicate =
-                       index_insert(idx, alias, sym->owner->modname, sym->owner->idx);
+               s = scratchbuf_str(&salias);
+               memcpy(s + baselen, sym->name, len + 1);
+               duplicate = index_insert(idx, s, sym->owner->modname, sym->owner->idx);
 
                if (duplicate && depmod->cfg->warn_dups)
-                       WRN("duplicate module syms:\n%s %s\n", alias, sym->owner->modname);
+                       WRN("duplicate module syms:\n%s %s\n", s, sym->owner->modname);
        }
 
        index_write(idx, out);