aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTharre <tharre3@gmail.com>2016-08-02 11:05:32 +0200
committerTharre <tharre3@gmail.com>2016-08-03 18:31:48 +0200
commit9ebc2a17515af7f7196362c9f7373fcea36c7835 (patch)
treef45fa798b4a882671a12927155c620cca86abcf5
parent220d44f961b0813b2786e45e069660dd37d15f67 (diff)
downloadredo-9ebc2a17515af7f7196362c9f7373fcea36c7835.tar.gz
redo-9ebc2a17515af7f7196362c9f7373fcea36c7835.tar.xz
redo-9ebc2a17515af7f7196362c9f7373fcea36c7835.zip
Fix overflow error when there are too many fields
-rw-r--r--src/DSV.c11
-rw-r--r--src/build.c2
2 files changed, 7 insertions, 6 deletions
diff --git a/src/DSV.c b/src/DSV.c
index 91cc7ee..1a46007 100644
--- a/src/DSV.c
+++ b/src/DSV.c
@@ -117,17 +117,18 @@ int dsv_parse_next_line(struct dsv_ctx *context, const char *src, size_t len) {
break;
}
+ if (i >= context->fields_count) {
+ debug("DSV: too many fields\n");
+ context->status = E_TOO_MANY_FIELDS;
+ goto error;
+ }
+
char *buf = xmalloc(size+1);
decode_string(buf, start, size+1);
context->fields[i] = buf;
start += size + 1;
++i;
- if (i > context->fields_count) {
- debug("DSV: too many fields\n");
- context->status = E_TOO_MANY_FIELDS;
- goto error;
- }
}
if (i+1 < context->fields_count) {
diff --git a/src/build.c b/src/build.c
index 8903563..cd6f8dc 100644
--- a/src/build.c
+++ b/src/build.c
@@ -475,7 +475,7 @@ static int handle_c(dep_info *dep) {
if (dsv_parse_file(&ctx, fp)) {
retval = build_target(dep);
- goto exit;
+ goto exit2;
}
errno = 0;