summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorPali Rohár <pali.rohar@gmail.com>2014-09-29 00:45:17 +0200
committerPali Rohár <pali.rohar@gmail.com>2014-09-29 00:45:17 +0200
commit03c6c3899f6b2e1b9f3ff08817ef491eee99286f (patch)
tree8946e98f6b04db4c024e698309f3067a5aa382ec /src/main.c
parent1610debbd5aa1f9b2754c83968c81b9e4b76c20f (diff)
download0xFFFF-03c6c3899f6b2e1b9f3ff08817ef491eee99286f.tar.bz2
main: Fix memory corruption
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index fdd2b4b..2daf848 100644
--- a/src/main.c
+++ b/src/main.c
@@ -210,7 +210,7 @@ static void parse_image_arg(char * arg, struct image_list ** image_first) {
exit(1);
}
lseek(fd, 0, SEEK_SET);
- layout = malloc(len);
+ layout = malloc(len+1);
if ( ! layout ) {
ALLOC_ERROR();
exit(1);
@@ -219,6 +219,8 @@ static void parse_image_arg(char * arg, struct image_list ** image_first) {
ERROR_INFO("Cannot read %lu bytes from layout file %s", len, layout_file);
exit(1);
}
+ layout[len] = 0;
+ close(fd);
}
image = image_alloc_from_file(file, type, device, hwrevs, version, layout);