commit 41924d0262686b79b1634888e64e487b76ffdfb2
parent 56d451ebcff5b5d70136fbb93400daf99550f02e
Author: Joris Vink <joris@coders.se>
Date: Mon, 6 Mar 2017 23:16:59 +0100
make sure len isn't 0 from cli_file_read().
Diffstat:
1 file changed, 10 insertions(+), 0 deletions(-)
diff --git a/src/cli.c b/src/cli.c
@@ -656,6 +656,10 @@ cli_reload(int argc, char **argv)
cli_file_open("kore.pid", O_RDONLY, &fd);
cli_file_read(fd, &buf, &len);
cli_file_close(fd);
+
+ if (len == 0)
+ fatal("reload: pid file is empty");
+
buf[len - 1] = '\0';
pid = cli_strtonum(buf, 0, UINT_MAX);
@@ -1775,6 +1779,8 @@ cli_build_ldflags(struct buildopt *bopt)
cli_file_open(".objs/ldflags", O_RDONLY, &fd);
cli_file_read(fd, &buf, &len);
cli_file_close(fd);
+ if (len == 0)
+ fatal(".objs/ldflags is empty");
buf[len - 1] = '\0';
cli_buf_append(bopt->ldflags, buf, len);
@@ -1843,6 +1849,10 @@ cli_kore_features(struct buildopt *bopt, char **out, size_t *outlen)
cli_file_read(fd, &data, &len);
cli_file_close(fd);
free(path);
+
+ if (len == 0)
+ fatal(".objs/features is empty");
+
data[len - 1] = '\0';
*out = data;