mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] common: elf: use strdup_const for symmetry
@ 2026-01-05  8:33 Ahmad Fatoum
  2026-01-05  8:33 ` [PATCH 2/2] common: elf: use memcmp for fixed-size comparison Ahmad Fatoum
  2026-01-06  7:39 ` [PATCH 1/2] common: elf: use strdup_const for symmetry Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2026-01-05  8:33 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

The elf->filename is free'd by free_const, but it's always allocated
with strdup. Change this to strdup_const to be able to avoid duplicating
string literals.

Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 common/elf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/elf.c b/common/elf.c
index c68ea0be3fa6..e8126c9b64e7 100644
--- a/common/elf.c
+++ b/common/elf.c
@@ -315,7 +315,7 @@ static struct elf_image *elf_check_init(const char *filename)
 	}
 	close(fd);
 
-	elf->filename = strdup(filename);
+	elf->filename = strdup_const(filename);
 	if (!elf->filename) {
 		ret = -ENOMEM;
 		goto err_free_hdr_buf;
-- 
2.47.3




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-01-06  7:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-05  8:33 [PATCH 1/2] common: elf: use strdup_const for symmetry Ahmad Fatoum
2026-01-05  8:33 ` [PATCH 2/2] common: elf: use memcmp for fixed-size comparison Ahmad Fatoum
2026-01-06  7:39 ` [PATCH 1/2] common: elf: use strdup_const for symmetry Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox