From 5c54660f454c28a83d4b3c35b57cca9ad855f7e4 Mon Sep 17 00:00:00 2001 From: Michael Poole Date: Thu, 26 Jul 2007 23:15:23 -0400 Subject: [PATCH] Avoid trying to mmap() or read a zero-byte database file. src/recdb.c (parse_database): If the file is empty, we can just return an empty database without trying to mmap() it (zero-sized mmap generates EINVAL) or trying to read it. --- src/recdb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/recdb.c b/src/recdb.c index 17dbccc..cba9813 100644 --- a/src/recdb.c +++ b/src/recdb.c @@ -93,7 +93,7 @@ typedef struct recdb_outfile { } RECDB_OUT; #ifdef HAVE_MMAP -static int mmap_error=0; +static int mmap_error; #endif #define EOL '\n' @@ -616,6 +616,9 @@ parse_database(const char *filename) return NULL; } recdb.length = (size_t)statinfo.st_size; + if (recdb.length == 0) { + return alloc_database(); + } #ifdef HAVE_MMAP /* Try mmap */ -- 2.20.1