Hung-Te Lin (hun...@chromium.org) just uploaded a new patch set to gerrit, 
which you can find at http://review.coreboot.org/2203

-gerrit

commit eca182e60f74fa5df040c7bb72cc04aa40824768
Author: Hung-Te Lin <hun...@chromium.org>
Date:   Mon Jan 28 23:42:25 2013 +0800

    cbfstool: Use non-intrusive basename().
    
    Calling basename(3) may modify content, so we should implement an 
alternative to
    prevent corrupting file names.
    
    Change-Id: Ib4827f887542596feef16e7829b00444220b9922
    Signed-off-by: Hung-Te Lin <hun...@chromium.org>
---
 util/cbfstool/common.c | 12 ++++++++++--
 util/cbfstool/common.h |  3 +++
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/util/cbfstool/common.c b/util/cbfstool/common.c
index bf4f7b0..116ce0c 100644
--- a/util/cbfstool/common.c
+++ b/util/cbfstool/common.c
@@ -22,7 +22,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <libgen.h>
 #include "common.h"
 #include "cbfs.h"
 #include "elf.h"
@@ -282,11 +281,20 @@ uint64_t intfiletype(const char *name)
        return -1;
 }
 
+/* basename(3) may modify buffer, so we should use a tiny alternative. */
+const char *simple_basename(const char *name) {
+       const char *slash = strrchr(name, '/');
+       if (slash)
+               return slash + 1;
+       else
+               return name;
+}
+
 void print_cbfs_directory(const char *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,
+              simple_basename(filename), romsize / 1024,
               ntohl(master_header->bootblocksize),
               romsize, ntohl(master_header->offset), align,
               arch_to_string(arch));
diff --git a/util/cbfstool/common.h b/util/cbfstool/common.h
index ba6fab3..5f14cb1 100644
--- a/util/cbfstool/common.h
+++ b/util/cbfstool/common.h
@@ -40,6 +40,9 @@ extern int verbose;
 #define INFO(x...) { if (verbose > 0) fprintf(stderr, "INFO: " x); }
 #define DEBUG(x...) { if (verbose > 1) fprintf(stderr, "DEBUG: " x); }
 
+/* Utilities */
+const char *simple_basename(const char *name);
+
 extern void *offset;
 extern uint32_t romsize;
 extern int host_bigendian;

-- 
coreboot mailing list: coreboot@coreboot.org
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to