summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjakob <jakob@memeware.net>2017-06-26 12:38:08 -0400
committerjakob <jakob@memeware.net>2017-06-26 12:38:08 -0400
commitf1a78a551cabe3ce95e076defc03ab41cfa825b6 (patch)
treeda5fa64f8aa57b03a5057a6545596116944a9576
parenta26f9e063e2f3f715b87566126c51fc966354529 (diff)
Add archive integrity checks. (Thanks, AFL\!)
-rw-r--r--Makefile8
-rw-r--r--src/compress.c2
-rw-r--r--src/main.c4
3 files changed, 10 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 94d8380..97165b1 100644
--- a/Makefile
+++ b/Makefile
@@ -50,10 +50,10 @@ $(OBJDIR)/%.o: $(TSTDIR)/%.c
@echo " CC $(@:$(OBJDIR)/%=%)"
@$(CC) $(CFLAGS) -c -o $@ -I $(SRCDIR) $(TSTDIR)/$*.c
-test: bin/test
- @bin/test
+test: $(BINDIR)/test
+ @$(BINDIR)/test
clean:
- rm -f bin/* obj/*
+ rm -f $(BINDIR)/* $(OBJDIR)/*
-.PHONY: clean test
+.PHONY: all clean test
diff --git a/src/compress.c b/src/compress.c
index 4df5ef7..22b4c50 100644
--- a/src/compress.c
+++ b/src/compress.c
@@ -44,6 +44,8 @@ struct stream *stream_inflate(struct stream *s, size_t len,
int ret;
struct stream *new = stream_new(decompressed_len);
+ if (new == NULL)
+ return NULL;
do {
strm.avail_in = len;
diff --git a/src/main.c b/src/main.c
index d50ee4c..90fbb2f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -156,6 +156,10 @@ static void map_entries(char *path, struct params p) {
return;
}
+ if (h->table_offset > archive->len) {
+ fprintf(stderr, "Invalid table offset. Archive corrupt.\n");
+ return;
+ }
stream_seek(archive, h->table_offset, SEEK_SET);
struct stream *table = load_table(archive);