summaryrefslogtreecommitdiff
path: root/util/cbfstool/common.h
diff options
context:
space:
mode:
authorStefan Reinauer <stepan@coresystems.de>2009-09-22 15:55:01 +0000
committerStefan Reinauer <stepan@openbios.org>2009-09-22 15:55:01 +0000
commit853270af390f9e200f4a165ec55d3b2fa5246c0b (patch)
tree6567b87c2f645a5c0c29b39c277f1b5de95f19a3 /util/cbfstool/common.h
parent0e0655e6ef815524107481856e40266ba23248f1 (diff)
downloadcoreboot-853270af390f9e200f4a165ec55d3b2fa5246c0b.tar.xz
* guard all mallocs in cbfstool
* fix an issue that could lead to cbfstool writing outside of its allocated memory Signed-off-by: Stefan Reinauer <stepan@coresystems.de> Acked-by: Peter Stuge <peter@stuge.se> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@4653 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'util/cbfstool/common.h')
-rw-r--r--util/cbfstool/common.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/util/cbfstool/common.h b/util/cbfstool/common.h
index 944f215b5d..a41eb8a439 100644
--- a/util/cbfstool/common.h
+++ b/util/cbfstool/common.h
@@ -29,7 +29,7 @@ static void *phys_to_virt(uint32_t addr)
static uint32_t virt_to_phys(void *addr)
{
- return (long)(addr - offset) & 0xffffffff;
+ return (unsigned long)(addr - offset) & 0xffffffff;
}
#define ALIGN(val, by) (((val) + (by)-1)&~((by)-1))
@@ -61,3 +61,5 @@ int create_cbfs_image(const char *romfile, uint32_t romsize,
int add_file_to_cbfs(void *content, uint32_t contentsize, uint32_t location);
void print_cbfs_directory(const char *filename);
+
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))