From cc2c178727cdeca4eb9756637c2e09e50e0856e7 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 10 Apr 2013 14:29:07 -0400 Subject: utilfdt_read: pass back up the length of data read For a follow up commit, we want to be able to scan the buffer that was returned to us. In order to do that safely, we need to know how big the buffer actually is, so pass that back if requested. Signed-off-by: Mike Frysinger --- util.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'util.c') diff --git a/util.c b/util.c index 12f0614..c689ea7 100644 --- a/util.c +++ b/util.c @@ -197,7 +197,7 @@ char get_escape_char(const char *s, int *i) return val; } -int utilfdt_read_err(const char *filename, char **buffp) +int utilfdt_read_err(const char *filename, char **buffp, off_t *len) { int fd = 0; /* assume stdin */ char *buf = NULL; @@ -238,13 +238,15 @@ int utilfdt_read_err(const char *filename, char **buffp) free(buf); else *buffp = buf; + if (len) + *len = bufsize; return ret; } -char *utilfdt_read(const char *filename) +char *utilfdt_read(const char *filename, off_t *len) { char *buff; - int ret = utilfdt_read_err(filename, &buff); + int ret = utilfdt_read_err(filename, &buff, len); if (ret) { fprintf(stderr, "Couldn't open blob from '%s': %s\n", filename, -- cgit v1.1