Don't touch v2+ rzdb files 0.3
authorJ. Ali Harlow <ali@juiblex.co.uk>
Thu, 1 Oct 2009 18:35:56 +0000 (19:35 +0100)
committerJ. Ali Harlow <ali@juiblex.co.uk>
Thu, 1 Oct 2009 19:02:23 +0000 (20:02 +0100)
librazor/razor.c

index b3f9c6a..5a9d848 100644 (file)
@@ -143,6 +143,14 @@ razor_set_bind_sections(struct razor_set *set, const char *filename)
                return -1;
        }
 
+       if (file->size < sizeof *file->header ||
+           file->header->magic != RAZOR_MAGIC ||
+           file->header->version != RAZOR_VERSION) {
+               razor_file_free_contents(file->header, file->size);
+               free(file);
+               return -1;
+       }
+
        if (set->mapped_files == NULL) {
                for (i = 0; i < ARRAY_SIZE(razor_sections); i++) {
                        array = (void *) set + razor_sections[i].offset;