summaryrefslogtreecommitdiffstats
path: root/libflashrom.c
diff options
context:
space:
mode:
authorNico Huber <nico.h@gmx.de>2019-06-15 14:56:19 +0200
committerNico Huber <nico.h@gmx.de>2019-06-17 08:32:43 +0000
commit70461a9524fc84ec5c095f11927cffa0429a6267 (patch)
tree0df6b67aec1d936bf8b39a86d5d9ed97ef5aa125 /libflashrom.c
parent4f213285d78974c4b8915b311aff88449279f554 (diff)
downloadflashrom-70461a9524fc84ec5c095f11927cffa0429a6267.tar.gz
flashrom-70461a9524fc84ec5c095f11927cffa0429a6267.tar.bz2
flashrom-70461a9524fc84ec5c095f11927cffa0429a6267.zip
layout: Make `romentry.name` a pointer
This should provide more flexibility while we don't have to allocate 256B extra per layout entry. Change-Id: Ibb903113550ec13f43cbbd0a412c8f35fe1cf454 Signed-off-by: Nico Huber <nico.h@gmx.de> Reviewed-on: https://review.coreboot.org/c/flashrom/+/33515 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
Diffstat (limited to 'libflashrom.c')
-rw-r--r--libflashrom.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/libflashrom.c b/libflashrom.c
index 721a11cfc..af62002a6 100644
--- a/libflashrom.c
+++ b/libflashrom.c
@@ -20,6 +20,7 @@
* Have a look at the Modules section for a function reference.
*/
+#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
@@ -384,9 +385,12 @@ static int flashrom_layout_parse_fmap(struct flashrom_layout **layout,
l->entries[l->num_entries].start = fmap->areas[i].offset;
l->entries[l->num_entries].end = fmap->areas[i].offset + fmap->areas[i].size - 1;
l->entries[l->num_entries].included = false;
- memset(l->entries[l->num_entries].name, 0, sizeof(l->entries[i].name));
- memcpy(l->entries[l->num_entries].name, fmap->areas[i].name,
- min(FMAP_STRLEN, sizeof(l->entries[i].name)));
+ l->entries[l->num_entries].name =
+ strndup((const char *)fmap->areas[i].name, FMAP_STRLEN);
+ if (!l->entries[l->num_entries].name) {
+ msg_gerr("Error adding layout entry: %s\n", strerror(errno));
+ return 1;
+ }
msg_gdbg("fmap %08x - %08x named %s\n",
l->entries[l->num_entries].start,
l->entries[l->num_entries].end,