Skip to content

Commit

Permalink
bugfix with invalid/corrupted index path
Browse files Browse the repository at this point in the history
  • Loading branch information
simon987 committed Nov 12, 2019
1 parent fc22e52 commit 6931d32
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/io/serialize.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ index_descriptor_t read_index_descriptor(char *path) {
struct stat info;
stat(path, &info);
int fd = open(path, O_RDONLY);

if (fd == -1) {
fprintf(stderr, "Invalid/corrupt index (Could not find descriptor)");
exit(1);
}

char *buf = malloc(info.st_size + 1);
read(fd, buf, info.st_size);
*(buf + info.st_size) = '\0';
Expand Down

0 comments on commit 6931d32

Please sign in to comment.