X-Git-Url: https://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=discover%2Fparser.c;h=8d4c180c2c1bccc7a3a43f1da996c09f5b901f65;hp=42ee2e55c9a0f352949e26551abc5c344bd1d84a;hb=7c8683fa009115f8a3b08b7a7666b64ebcbbc1bc;hpb=19dab336ae13f0476bfbf0db34f1329a802eeb8e diff --git a/discover/parser.c b/discover/parser.c index 42ee2e5..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; @@ -142,8 +144,10 @@ void iterate_parsers(struct discover_context *ctx, enum conf_method method) case CONF_METHOD_DHCP: rc = download_config(ctx, &buf, &len); - if (rc) + if (rc) { + pb_log("\tdownload failed, aborting\n"); return; + } for (i = 0; i < n_parsers; i++) { if (parsers[i]->method != method)