summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2013-05-10 10:47:24 +0800
committerJeremy Kerr <jk@ozlabs.org>2013-05-15 14:37:35 +0800
commit7c8683fa009115f8a3b08b7a7666b64ebcbbc1bc (patch)
treeff25b865d09ebfb27d1430599ded3e3a5096769f
parent3fb8fb6fb6259e7b0894cb3756ea02dbe2d361f3 (diff)
downloadtalos-petitboot-7c8683fa009115f8a3b08b7a7666b64ebcbbc1bc.tar.gz
talos-petitboot-7c8683fa009115f8a3b08b7a7666b64ebcbbc1bc.zip
discover: Always add a NUL byte to config data
conf_get_pair will read one-byte past the end of the conf buffer, so always NUL-terminate. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
-rw-r--r--discover/parser.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/discover/parser.c b/discover/parser.c
index 11728b7..8d4c180 100644
--- a/discover/parser.c
+++ b/discover/parser.c
@@ -37,7 +37,7 @@ static int read_file(struct discover_context *ctx,
if (len > max_file_size)
goto err_close;
- buf = talloc_array(ctx, char, len);
+ buf = talloc_array(ctx, char, len + 1);
if (!buf)
goto err_close;
@@ -55,6 +55,8 @@ static int read_file(struct discover_context *ctx,
}
+ buf[len] = '\0';
+
close(fd);
*bufp = buf;
*lenp = len;
OpenPOWER on IntegriCloud