summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcsapuntz <csapuntz@openbsd.org>2001-04-10 17:35:40 +0000
committercsapuntz <csapuntz@openbsd.org>2001-04-10 17:35:40 +0000
commitb0728fab357b0002e8b348a666bf57aea6ffa1a0 (patch)
treef60f0c1526d206f8a83e13cf2773e2bc8df36fc3
parentRemove lies about printf vs. puts/fputs/putchar. (diff)
downloadwireguard-openbsd-b0728fab357b0002e8b348a666bf57aea6ffa1a0.tar.xz
wireguard-openbsd-b0728fab357b0002e8b348a666bf57aea6ffa1a0.zip
Don't seg-fault on file systems that don't support cookies. Thanks to
Jason Ish for finding this one.
-rw-r--r--sys/compat/common/compat_dir.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/sys/compat/common/compat_dir.c b/sys/compat/common/compat_dir.c
index e7ecbd1e53f..74afaf81e36 100644
--- a/sys/compat/common/compat_dir.c
+++ b/sys/compat/common/compat_dir.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: compat_dir.c,v 1.1 2001/01/23 05:48:04 csapuntz Exp $ */
+/* $OpenBSD: compat_dir.c,v 1.2 2001/04/10 17:35:40 csapuntz Exp $ */
/*
* Copyright (c) 2000 Constantine Sapuntzakis
@@ -52,7 +52,7 @@ readdir_with_callback(fp, off, nbytes, appendfunc, arg)
int buflen;
struct uio auio;
struct iovec aiov;
- int eofflag;
+ int eofflag = 0;
u_long *cookiebuf = NULL, *cookie;
int ncookies = 0;
int error, len, reclen;
@@ -94,14 +94,14 @@ again:
if (error)
goto out;
- if (!cookiebuf && !eofflag) {
+ if ((len = buflen - auio.uio_resid) == 0)
+ goto eof;
+
+ if (cookiebuf == NULL) {
error = EPERM;
goto out;
}
- if ((len = buflen - auio.uio_resid) == 0)
- goto eof;
-
cookie = cookiebuf;
inp = buf;