summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbrad <brad@openbsd.org>2014-11-08 22:13:47 +0000
committerbrad <brad@openbsd.org>2014-11-08 22:13:47 +0000
commitb32f2c1b2453d6db539c06546cd87424026f2c7a (patch)
treed9ce7cc23340eec1c6b422cc065f80af11908e30
parentUse open(O_CLOEXEC) rather than open() + fcntl(FD_CLOEXEC). Inspired (diff)
downloadwireguard-openbsd-b32f2c1b2453d6db539c06546cd87424026f2c7a.tar.xz
wireguard-openbsd-b32f2c1b2453d6db539c06546cd87424026f2c7a.zip
Check the mode flag being passed in to mmopen() instead of ignoring it.
Pointed out by LLVM. mmfile.c:51:7: warning: explicitly assigning a variable of type 'char *' to itself [-Wself-assign] ok millert@
-rw-r--r--usr.bin/grep/mmfile.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.bin/grep/mmfile.c b/usr.bin/grep/mmfile.c
index a2a49e49035..4a985b1d5bc 100644
--- a/usr.bin/grep/mmfile.c
+++ b/usr.bin/grep/mmfile.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mmfile.c,v 1.14 2011/07/17 12:17:10 aschrijver Exp $ */
+/* $OpenBSD: mmfile.c,v 1.15 2014/11/08 22:13:47 brad Exp $ */
/*-
* Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav
@@ -47,8 +47,8 @@ mmopen(char *fn, char *mode)
mmf_t *mmf;
struct stat st;
- /* XXX ignore mode for now */
- mode = mode;
+ if (*mode != 'r')
+ return NULL;
mmf = grep_malloc(sizeof *mmf);
if ((mmf->fd = open(fn, O_RDONLY)) == -1)