From: Tobias Stoeckmann Date: Mon, 30 Sep 2024 16:54:54 +0000 (+0200) Subject: depmod: Clarify the meaning of char array "alias" X-Git-Tag: v34~270 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e7db27b058fc690a540c104f2809ab8e3c2bd995;p=thirdparty%2Fkmod.git depmod: Clarify the meaning of char array "alias" It is meant as a backing buffer for scratch buffer. Do not use it directly when constructing strings. Co-authored-by: Lucas De Marchi Signed-off-by: Tobias Stoeckmann Link: https://github.com/kmod-project/kmod/pull/166 Signed-off-by: Lucas De Marchi --- diff --git a/tools/depmod.c b/tools/depmod.c index 3117b78e..9461dddd 100644 --- a/tools/depmod.c +++ b/tools/depmod.c @@ -2307,10 +2307,10 @@ static int output_symbols(struct depmod *depmod, FILE *out) static int output_symbols_bin(struct depmod *depmod, FILE *out) { struct index_node *idx; - char alias[1024]; + char aliasbuf[1024] = "symbol:"; _cleanup_(scratchbuf_release) struct scratchbuf salias = - SCRATCHBUF_INITIALIZER(alias); - size_t baselen = sizeof("symbol:") - 1; + SCRATCHBUF_INITIALIZER(aliasbuf); + const size_t baselen = sizeof("symbol:") - 1; struct hash_iter iter; const void *v; int ret = 0; @@ -2322,8 +2322,6 @@ static int output_symbols_bin(struct depmod *depmod, FILE *out) if (idx == NULL) return -ENOMEM; - memcpy(alias, "symbol:", baselen); - hash_iter_init(depmod->symbols, &iter); while (hash_iter_next(&iter, NULL, &v)) {