From 86ecc45306dadadcf4b4e5b7de6c63223cde4873 Mon Sep 17 00:00:00 2001 From: fvdl Date: Fri, 10 Oct 1997 01:47:41 +0000 Subject: [PATCH] Signal error when getting a 64 bit offset cookie that can't be stored in 32 bits. Provide an error message to the user, and return EINVAL. Also, pay attention to the EOF flag from VOP_READDIR. Correct a misspell in a panic message. --- sys/compat/sunos/sunos_misc.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sys/compat/sunos/sunos_misc.c b/sys/compat/sunos/sunos_misc.c index 7ab13630b669..a1068528d079 100644 --- a/sys/compat/sunos/sunos_misc.c +++ b/sys/compat/sunos/sunos_misc.c @@ -1,4 +1,4 @@ -/* $NetBSD: sunos_misc.c,v 1.81 1997/08/04 09:48:10 bouyer Exp $ */ +/* $NetBSD: sunos_misc.c,v 1.82 1997/10/10 01:47:41 fvdl Exp $ */ /* * Copyright (c) 1992, 1993 @@ -439,7 +439,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; + off_t *cookiebuf, *cookie; int ncookies; if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) @@ -481,7 +481,7 @@ again: inp = buf; outp = SCARG(uap, buf); resid = SCARG(uap, nbytes); - if ((len = buflen - auio.uio_resid) == 0) + if (eofflag || (len = buflen - auio.uio_resid) == 0) goto eof; for (cookie = cookiebuf; len > 0; len -= reclen) { @@ -489,6 +489,11 @@ again: reclen = bdp->d_reclen; if (reclen & 3) panic("sunos_getdents"); + if ((*cookie >> 32) != 0) { + compat_offseterr(vp, "sunos_getdents"); + error = EINVAL; + goto out; + } if (bdp->d_fileno == 0) { inp += reclen; /* it is a hole; squish it out */ off = *cookie++;