summaryrefslogtreecommitdiff
path: root/sys/compat/sunos/sunos_misc.c
diff options
context:
space:
mode:
authorConstantine Sapuntzakis <csapuntz@cvs.openbsd.org>1997-11-06 05:59:40 +0000
committerConstantine Sapuntzakis <csapuntz@cvs.openbsd.org>1997-11-06 05:59:40 +0000
commit4e165724f1631d1deee6fd89b941fabdbcc855d4 (patch)
tree3aca36af68e90377984b00e9f0050674b0763db5 /sys/compat/sunos/sunos_misc.c
parentfec1be888534eb37405f6bf7a195f28670e1392b (diff)
Updates for VFS Lite 2 + soft update.
Diffstat (limited to 'sys/compat/sunos/sunos_misc.c')
-rw-r--r--sys/compat/sunos/sunos_misc.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/sys/compat/sunos/sunos_misc.c b/sys/compat/sunos/sunos_misc.c
index b17091d236a..73b6c220499 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.13 1997/10/06 20:19:33 deraadt Exp $ */
+/* $OpenBSD: sunos_misc.c,v 1.14 1997/11/06 05:58:05 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);
}