summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2017-08-26 20:38:10 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2017-08-26 20:38:10 +0000
commit6b42b5938cbe29ee22346a03b5279ea6efad53d9 (patch)
tree65c213af08f6a3821a9aebfa111bcb494bdfd3d8 /usr.bin
parentabc9a9d34ef7f44adc67547498f4be1971dde4ac (diff)
Fix previous: mmap(2) returns MAP_FAILED on failure, not NULL.
Bug pointed out by tedu@.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mandoc/mandocdb.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/usr.bin/mandoc/mandocdb.c b/usr.bin/mandoc/mandocdb.c
index 6528d9fb6ac..827ea2084d2 100644
--- a/usr.bin/mandoc/mandocdb.c
+++ b/usr.bin/mandoc/mandocdb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mandocdb.c,v 1.204 2017/08/26 15:55:41 schwarze Exp $ */
+/* $OpenBSD: mandocdb.c,v 1.205 2017/08/26 20:38:09 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -2114,7 +2114,7 @@ dbwrite(struct dba *dba)
say("", "&%s", tfn);
return;
}
- cp1 = cp2 = NULL;
+ cp1 = cp2 = MAP_FAILED;
fd1 = fd2 = -1;
(void)strlcat(tfn, "/" MANDOC_DB, sizeof(tfn));
if (dba_write(tfn, dba) == -1) {
@@ -2140,12 +2140,12 @@ dbwrite(struct dba *dba)
if (sb1.st_size != sb2.st_size)
goto err;
if ((cp1 = mmap(NULL, sb1.st_size, PROT_READ, MAP_PRIVATE,
- fd1, 0)) == NULL) {
+ fd1, 0)) == MAP_FAILED) {
say(MANDOC_DB, "&mmap");
goto err;
}
if ((cp2 = mmap(NULL, sb2.st_size, PROT_READ, MAP_PRIVATE,
- fd2, 0)) == NULL) {
+ fd2, 0)) == MAP_FAILED) {
say(tfn, "&mmap");
goto err;
}
@@ -2159,9 +2159,9 @@ err:
say(MANDOC_DB, "Data changed, but cannot replace database");
out:
- if (cp1 != NULL)
+ if (cp1 != MAP_FAILED)
munmap(cp1, sb1.st_size);
- if (cp2 != NULL)
+ if (cp2 != MAP_FAILED)
munmap(cp2, sb2.st_size);
if (fd1 != -1)
close(fd1);