diff options
author | Constantine Sapuntzakis <csapuntz@cvs.openbsd.org> | 1997-10-06 15:08:48 +0000 |
---|---|---|
committer | Constantine Sapuntzakis <csapuntz@cvs.openbsd.org> | 1997-10-06 15:08:48 +0000 |
commit | 486c8e78cbcef0d475b10f58a45c8977765ead46 (patch) | |
tree | a4ca5659a570c2e513cd1ae483effe8442c72fdb /sys/compat/sunos | |
parent | 9edf2581c6553b9af6c80d28f1027b44776020d3 (diff) |
VFS Lite2 Changes
Diffstat (limited to 'sys/compat/sunos')
-rw-r--r-- | sys/compat/sunos/sunos_misc.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/sys/compat/sunos/sunos_misc.c b/sys/compat/sunos/sunos_misc.c index 1af211391e0..e062dbf9c80 100644 --- a/sys/compat/sunos/sunos_misc.c +++ b/sys/compat/sunos/sunos_misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sunos_misc.c,v 1.11 1997/07/28 09:53:12 deraadt Exp $ */ +/* $OpenBSD: sunos_misc.c,v 1.12 1997/10/06 15:05:45 csapuntz Exp $ */ /* $NetBSD: sunos_misc.c,v 1.65 1996/04/22 01:44:31 christos Exp $ */ /* @@ -412,7 +412,7 @@ sunos_sys_getdents(p, v, retval) struct sunos_dirent idb; off_t off; /* true file offset */ int buflen, error, eofflag; - u_long *cookiebuf, *cookie; + u_long *cookiebuf = NULL, *cookie; int ncookies; if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) @@ -428,8 +428,6 @@ sunos_sys_getdents(p, v, retval) buflen = min(MAXBSIZE, SCARG(uap, nbytes)); buf = malloc(buflen, M_TEMP, M_WAITOK); - ncookies = buflen / 16; - cookiebuf = malloc(ncookies * sizeof(*cookiebuf), M_TEMP, M_WAITOK); VOP_LOCK(vp); off = fp->f_offset; again: @@ -446,10 +444,15 @@ again: * First we read into the malloc'ed buffer, then * we massage it into user space, one record at a time. */ - error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, cookiebuf, - ncookies); + error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, + &ncookies, &cookiebuf); if (error) goto out; + + if (!error && !cookiebuf) { + error = EPERM; + goto out; + } inp = buf; outp = SCARG(uap, buf); @@ -501,7 +504,8 @@ eof: *retval = SCARG(uap, nbytes) - resid; out: VOP_UNLOCK(vp); - free(cookiebuf, M_TEMP); + if (cookiebuf) + free(cookiebuf, M_TEMP); free(buf, M_TEMP); return (error); } |