From e7db27b058fc690a540c104f2809ab8e3c2bd995 Mon Sep 17 00:00:00 2001 From: Tobias Stoeckmann Date: Mon, 30 Sep 2024 18:54:54 +0200 Subject: [PATCH] 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 --- tools/depmod.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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)) { -- 2.47.3