Commit 0c8ba26f authored by Aurelio Colosimo's avatar Aurelio Colosimo

conf parsing: add a \n at the end of allocated buffer

This patch permits to properly parse ppsi.conf files even if it is
not terminated with a newline. Thanks to Alessandro Rubini for the hint.
Signed-off-by: Aurelio Colosimo's avatarAurelio Colosimo <aurelio@aureliocolosimo.it>
parent 91c3935e
......@@ -56,7 +56,7 @@ int main(int argc, char **argv)
}
else {
int r = 0, next_r;
conf_buf = calloc(1, conf_fs.st_size + 1);
conf_buf = calloc(1, conf_fs.st_size + 2);
do {
next_r = conf_fs.st_size - conf_len;
......@@ -69,6 +69,8 @@ int main(int argc, char **argv)
close(conf_fd);
}
conf_buf[conf_len + 1] = '\n';
ppg->rt_opts = &default_rt_opts;
if ((ret = pp_parse_conf(ppg, conf_buf, conf_len)) < 0) {
......
......@@ -72,7 +72,7 @@ int main(int argc, char **argv)
}
else {
int r = 0, next_r;
conf_buf = calloc(1, conf_fs.st_size + 1);
conf_buf = calloc(1, conf_fs.st_size + 2);
do {
next_r = conf_fs.st_size - conf_len;
......@@ -85,6 +85,8 @@ int main(int argc, char **argv)
close(conf_fd);
}
conf_buf[conf_len + 1] = '\n';
ppg->rt_opts = &default_rt_opts;
if ((ret = pp_parse_conf(ppg, conf_buf, conf_len)) < 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment