Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/look Properly check mmap(2) return value. We can end...
details: https://anonhg.NetBSD.org/src/rev/e8876178166e
branches: trunk
changeset: 821901:e8876178166e
user: leot <leot%NetBSD.org@localhost>
date: Tue Feb 21 09:23:31 2017 +0000
description:
Properly check mmap(2) return value. We can end up with a segmentation
fault if the user does not provide a regular file as look(1) file
argument.
Kindly reviewed by <Riastradh>
diffstat:
usr.bin/look/look.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diffs (27 lines):
diff -r aa4cd395b3bc -r e8876178166e usr.bin/look/look.c
--- a/usr.bin/look/look.c Tue Feb 21 08:40:16 2017 +0000
+++ b/usr.bin/look/look.c Tue Feb 21 09:23:31 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: look.c,v 1.16 2012/02/23 22:57:53 joerg Exp $ */
+/* $NetBSD: look.c,v 1.17 2017/02/21 09:23:31 leot Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -42,7 +42,7 @@
#if 0
static char sccsid[] = "@(#)look.c 8.2 (Berkeley) 5/4/95";
#endif
-__RCSID("$NetBSD: look.c,v 1.16 2012/02/23 22:57:53 joerg Exp $");
+__RCSID("$NetBSD: look.c,v 1.17 2017/02/21 09:23:31 leot Exp $");
#endif /* not lint */
/*
@@ -147,7 +147,7 @@
err(2, "%s", file);
}
if ((front = mmap(NULL, len,
- PROT_READ, MAP_FILE|MAP_SHARED, fd, (off_t)0)) == NULL)
+ PROT_READ, MAP_FILE|MAP_SHARED, fd, (off_t)0)) == MAP_FAILED)
err(2, "%s", file);
back = front + len;
exit(look(string, front, back));
Home |
Main Index |
Thread Index |
Old Index