projects
/
srvx.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
5c7a8fc
)
Avoid trying to mmap() or read a zero-byte database file.
author
Michael Poole
<mdpoole@troilus.org>
Fri, 27 Jul 2007 03:15:23 +0000
(23:15 -0400)
committer
Michael Poole
<mdpoole@troilus.org>
Fri, 27 Jul 2007 03:15:42 +0000
(23:15 -0400)
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
patch
|
blob
|
history
diff --git
a/src/recdb.c
b/src/recdb.c
index 17dbccc958b9f4c85aba4774e45a84745fd3c387..cba98139082c0d1e03a6fb7c431d52d471f8642b 100644
(file)
--- 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 */