From 5a9f45c757b48235d86018bee2d20f9e35d7e1d7 Mon Sep 17 00:00:00 2001 From: Hung-Te Lin Date: Mon, 28 Jan 2013 23:42:25 +0800 Subject: cbfstool: Prevent file name to be corrupted by basename(). Calling basename(3) may modify content. We should allocate another buffer to prevent corrupting input buffer (full file path names). Change-Id: Ib4827f887542596feef16e7829b00444220b9922 Signed-off-by: Hung-Te Lin Reviewed-on: http://review.coreboot.org/2203 Reviewed-by: Ronald G. Minnich Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel --- util/cbfstool/common.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'util/cbfstool/common.c') diff --git a/util/cbfstool/common.c b/util/cbfstool/common.c index 97bf168402ee..137aeb7bb8e9 100644 --- a/util/cbfstool/common.c +++ b/util/cbfstool/common.c @@ -273,11 +273,13 @@ uint64_t intfiletype(const char *name) void print_cbfs_directory(const char *filename) { + char *name = strdup(filename); printf ("%s: %d kB, bootblocksize %d, romsize %d, offset 0x%x\n" "alignment: %d bytes, architecture: %s\n\n", - basename((char *)filename), romsize / 1024, ntohl(master_header->bootblocksize), + basename(name), romsize / 1024, ntohl(master_header->bootblocksize), romsize, ntohl(master_header->offset), align, arch_to_string(arch)); + free(name); printf("%-30s %-10s %-12s Size\n", "Name", "Offset", "Type"); uint32_t current = phys_start; while (current < phys_end) { -- cgit v1.2.3