Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libintl fix mmap() return value validation. comment fro...
details: https://anonhg.NetBSD.org/src/rev/bdd52f1a0b25
branches: trunk
changeset: 500666:bdd52f1a0b25
user: itojun <itojun%NetBSD.org@localhost>
date: Fri Dec 15 06:37:21 2000 +0000
description:
fix mmap() return value validation. comment from freebsd-audit.
diffstat:
lib/libintl/gettext.c | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diffs (46 lines):
diff -r 73aa57b588be -r bdd52f1a0b25 lib/libintl/gettext.c
--- a/lib/libintl/gettext.c Fri Dec 15 06:14:21 2000 +0000
+++ b/lib/libintl/gettext.c Fri Dec 15 06:37:21 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gettext.c,v 1.6 2000/12/14 02:06:12 itojun Exp $ */
+/* $NetBSD: gettext.c,v 1.7 2000/12/15 06:37:21 itojun Exp $ */
/*-
* Copyright (c) 2000 Citrus Project,
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: gettext.c,v 1.6 2000/12/14 02:06:12 itojun Exp $");
+__RCSID("$NetBSD: gettext.c,v 1.7 2000/12/15 06:37:21 itojun Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -310,7 +310,8 @@
int i;
char *v;
- if (mohandle.addr && strcmp(path, mohandle.path) == 0)
+ if (mohandle.addr && mohandle.addr != MAP_FAILED &&
+ strcmp(path, mohandle.path) == 0)
return 0; /*already opened*/
unmapit();
@@ -338,7 +339,7 @@
}
mohandle.addr = mmap(NULL, (size_t)st.st_size, PROT_READ,
MAP_FILE | MAP_SHARED, fd, (off_t)0);
- if (!mohandle.addr) {
+ if (!mohandle.addr || mohandle.addr == MAP_FAILED) {
close(fd);
goto fail;
}
@@ -433,7 +434,7 @@
{
/* unmap if there's already mapped region */
- if (mohandle.addr)
+ if (mohandle.addr && mohandle.addr != MAP_FAILED)
munmap(mohandle.addr, mohandle.len);
mohandle.addr = NULL;
mohandle.path[0] = '\0';
Home |
Main Index |
Thread Index |
Old Index