diff options
author | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1999-02-10 00:16:13 +0000 |
---|---|---|
committer | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1999-02-10 00:16:13 +0000 |
commit | 3e01cdc2fb4d15a5bd8a0675450ba943bc9a0059 (patch) | |
tree | f8ae8011cd8a05047f8e60574cf4e7fe7d5050c6 /sys/compat | |
parent | 89bb5cf80c913788c0ea306ae547b6e180496f15 (diff) |
Correct directory entry reads, big directories lost entries as it were.
Also, fix the NCR SVR4 rdebug syscall emulation.
Diffstat (limited to 'sys/compat')
-rw-r--r-- | sys/compat/ibcs2/ibcs2_misc.c | 19 | ||||
-rw-r--r-- | sys/compat/linux/linux_misc.c | 7 | ||||
-rw-r--r-- | sys/compat/sunos/sunos_misc.c | 7 | ||||
-rw-r--r-- | sys/compat/svr4/svr4_misc.c | 14 |
4 files changed, 29 insertions, 18 deletions
diff --git a/sys/compat/ibcs2/ibcs2_misc.c b/sys/compat/ibcs2/ibcs2_misc.c index e7c66cefa2c..793eaba953a 100644 --- a/sys/compat/ibcs2/ibcs2_misc.c +++ b/sys/compat/ibcs2/ibcs2_misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ibcs2_misc.c,v 1.13 1997/11/06 05:58:03 csapuntz Exp $ */ +/* $OpenBSD: ibcs2_misc.c,v 1.14 1999/02/10 00:16:11 niklas Exp $ */ /* $NetBSD: ibcs2_misc.c,v 1.23 1997/01/15 01:37:49 perry Exp $ */ /* @@ -395,7 +395,7 @@ again: if (error) goto out; - if (!error && !cookiebuf) { + if (!error && !cookiebuf && !eofflag) { error = EPERM; goto out; } @@ -410,10 +410,10 @@ again: bdp = (struct dirent *)inp; reclen = bdp->d_reclen; if (reclen & 3) - panic("ibcs2_getdents"); - off = *cookie++; /* each entry points to the next */ + panic("ibcs2_getdents: bad reclen"); if (bdp->d_fileno == 0) { inp += reclen; /* it is a hole; squish it out */ + off = *cookie++; continue; } ibcs2_reclen = IBCS2_RECLEN(&idb, bdp->d_namlen); @@ -422,6 +422,8 @@ again: outp++; break; } + off = *cookie++; /* each entry points to the next */ + /* * Massage in place to make a iBCS2-shaped dirent (otherwise * we have to worry about touching user memory outside of @@ -434,8 +436,10 @@ again: error = copyout((caddr_t)&idb, outp, ibcs2_reclen); if (error) goto out; + /* advance past this real entry */ inp += reclen; + /* advance output past iBCS2-shaped entry */ outp += ibcs2_reclen; resid -= ibcs2_reclen; @@ -520,7 +524,7 @@ again: if (error) goto out; - if (!error && !cookiebuf) { + if (!error && !cookiebuf && !eofflag) { error = EPERM; goto out; } @@ -534,10 +538,10 @@ again: bdp = (struct dirent *)inp; reclen = bdp->d_reclen; if (reclen & 3) - panic("ibcs2_read"); - off = *cookie++; /* each entry points to the next */ + panic("ibcs2_read: bad reclen"); if (bdp->d_fileno == 0) { inp += reclen; /* it is a hole; squish it out */ + off = *cookie++; continue; } ibcs2_reclen = 16; @@ -546,6 +550,7 @@ again: outp++; break; } + off = *cookie++; /* each entry points to the next */ /* * Massage in place to make a iBCS2-shaped dirent (otherwise * we have to worry about touching user memory outside of diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c index 0c55ea08585..b728b758d24 100644 --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: linux_misc.c,v 1.18 1998/07/05 20:49:12 downsj Exp $ */ +/* $OpenBSD: linux_misc.c,v 1.19 1999/02/10 00:16:12 niklas Exp $ */ /* $NetBSD: linux_misc.c,v 1.27 1996/05/20 01:59:21 fvdl Exp $ */ /* @@ -853,7 +853,7 @@ again: bdp = (struct dirent *)inp; reclen = bdp->d_reclen; if (reclen & 3) - panic("linux_readdir"); + panic("linux_readdir: bad reclen"); if (bdp->d_fileno == 0) { inp += reclen; /* it is a hole; squish it out */ off = *cookie++; @@ -863,15 +863,16 @@ again: if (reclen > len || resid < linux_reclen) { /* entry too big for buffer, so just stop */ outp++; - off = *cookie++; break; } + /* * Massage in place to make a Linux-shaped dirent (otherwise * we have to worry about touching user memory outside of * the copyout() call). */ idb.d_ino = (linux_ino_t)bdp->d_fileno; + /* * The old readdir() call misuses the offset and reclen fields. */ diff --git a/sys/compat/sunos/sunos_misc.c b/sys/compat/sunos/sunos_misc.c index 8d1cfb82e8c..c7afdbe8b4d 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.20 1998/03/23 07:12:39 millert Exp $ */ +/* $OpenBSD: sunos_misc.c,v 1.21 1999/02/10 00:16:12 niklas Exp $ */ /* $NetBSD: sunos_misc.c,v 1.65 1996/04/22 01:44:31 christos Exp $ */ /* @@ -447,10 +447,10 @@ again: bdp = (struct dirent *)inp; reclen = bdp->d_reclen; if (reclen & 3) - panic("sunos_getdents"); - off = *cookie++; /* each entry points to next */ + panic("sunos_getdents: bad reclen"); if (bdp->d_fileno == 0) { inp += reclen; /* it is a hole; squish it out */ + off = *cookie++; continue; } sunos_reclen = SUNOS_RECLEN(&idb, bdp->d_namlen); @@ -459,6 +459,7 @@ again: outp++; break; } + off = *cookie++; /* each entry points to next */ /* * Massage in place to make a Sun-shaped dirent (otherwise * we have to worry about touching user memory outside of diff --git a/sys/compat/svr4/svr4_misc.c b/sys/compat/svr4/svr4_misc.c index 0cb46da13df..1a509b1da03 100644 --- a/sys/compat/svr4/svr4_misc.c +++ b/sys/compat/svr4/svr4_misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: svr4_misc.c,v 1.20 1998/03/06 21:58:09 niklas Exp $ */ +/* $OpenBSD: svr4_misc.c,v 1.21 1999/02/10 00:16:12 niklas Exp $ */ /* $NetBSD: svr4_misc.c,v 1.42 1996/12/06 03:22:34 christos Exp $ */ /* @@ -267,7 +267,7 @@ again: if (error) goto out; - if (!error && !cookiebuf) { + if (!error && !cookiebuf && !eofflag) { error = EPERM; goto out; } @@ -282,10 +282,10 @@ again: bdp = (struct dirent *)inp; reclen = bdp->d_reclen; if (reclen & 3) - panic("svr4_getdents"); - off = *cookie++; /* each entry points to the next */ + panic("svr4_getdents: bad reclen"); if (bdp->d_fileno == 0) { inp += reclen; /* it is a hole; squish it out */ + off = *cookie++; continue; } svr4_reclen = SVR4_RECLEN(&idb, bdp->d_namlen); @@ -294,6 +294,8 @@ again: outp++; break; } + off = *cookie++; /* each entry points to the next */ + /* * Massage in place to make a SVR4-shaped dirent (otherwise * we have to worry about touching user memory outside of @@ -305,8 +307,10 @@ again: strcpy(idb.d_name, bdp->d_name); if ((error = copyout((caddr_t)&idb, outp, svr4_reclen))) goto out; + /* advance past this real entry */ inp += reclen; + /* advance output past SVR4-shaped entry */ outp += svr4_reclen; resid -= svr4_reclen; @@ -1385,7 +1389,7 @@ svr4_sys_rdebug(p, v, retval) void *v; register_t *retval; { -#ifdef SVR4_COMPAT_NCR +#ifdef COMPAT_SVR4_NCR return (ENXIO); #else return (p->p_os == OOS_NCR ? ENXIO : sys_nosys(p, v, retval)); |