From: Michael Poole Date: Fri, 27 Jul 2007 03:15:23 +0000 (-0400) Subject: Avoid trying to mmap() or read a zero-byte database file. X-Git-Tag: v1.4.0-rc1~3 X-Git-Url: http://git.pk910.de/?p=srvx.git;a=commitdiff_plain;h=5c54660f454c28a83d4b3c35b57cca9ad855f7e4 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. --- 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 */