Miklós Márton has uploaded this change for review.
Removed strndup because it is not available in MingW
Signed-off-by: Miklós Márton <martonmiklosqdev@gmail.com>
Change-Id: If418080bffff1f5961cacf2a300ea9c666682458
---
M libflashrom.c
1 file changed, 10 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/21/34621/1
diff --git a/libflashrom.c b/libflashrom.c
index af62002..a1c0a9c 100644
--- a/libflashrom.c
+++ b/libflashrom.c
@@ -371,6 +371,7 @@
struct flashctx *const flashctx, const struct fmap *const fmap)
{
int i;
+ size_t len;
struct flashrom_layout *l = get_global_layout();
if (!fmap || !l)
@@ -385,8 +386,15 @@
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;
- l->entries[l->num_entries].name =
- strndup((const char *)fmap->areas[i].name, FMAP_STRLEN);
+ // MingW does not have strndup
+ len = strlen((const char *)fmap->areas[i].name);
+ if (len > (FMAP_STRLEN - 1))
+ len = (FMAP_STRLEN - 1);
+ l->entries[l->num_entries].name = malloc(len + 1);
+ strncpy(l->entries[l->num_entries].name,
+ (const char *)fmap->areas[i].name,
+ len);
+ l->entries[l->num_entries].name[len] = '\0';
if (!l->entries[l->num_entries].name) {
msg_gerr("Error adding layout entry: %s\n", strerror(errno));
return 1;
To view, visit change 34621. To unsubscribe, or for help writing mail filters, visit settings.