Permalink
Browse files

Use S_IS* macros insted of masking with S_IF* flags. The latter may

have multiple bits set, which lead to surprising results. Spotted by
Paul Stoeber, more to come. ok millert@ pedro@ jaredy@ djm@
  • Loading branch information...
1 parent 7d49611 commit a2c7fdfd2d8ce5073bf10bca9f61f30af6772db9 @omoerbeek omoerbeek committed with Sep 19, 2006
Showing with 2 additions and 2 deletions.
  1. +2 −2 mmfile.c
View
@@ -1,4 +1,4 @@
-/* $OpenBSD: mmfile.c,v 1.9 2004/10/03 19:23:02 otto Exp $ */
+/* $OpenBSD: mmfile.c,v 1.10 2006/02/09 09:54:47 otto Exp $ */
/*-
* Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav
@@ -55,7 +55,7 @@ mmopen(char *fn, char *mode)
goto ouch2;
if (st.st_size > SIZE_T_MAX) /* too big to mmap */
goto ouch2;
- if ((st.st_mode & S_IFREG) == 0) /* only mmap regular files */
+ if (!S_ISDIR(st.st_mode)) /* only mmap regular files */
goto ouch2;
mmf->len = (size_t)st.st_size;
mmf->base = mmap(NULL, mmf->len, PROT_READ, MAP_PRIVATE, mmf->fd, (off_t)0);

0 comments on commit a2c7fdf

Please sign in to comment.