initialize before use
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Thu, 5 Sep 1985 11:50:23 +0000 (03:50 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Thu, 5 Sep 1985 11:50:23 +0000 (03:50 -0800)
SCCS-vsn: sys/kern/vfs_lookup.c 6.25
SCCS-vsn: sys/ufs/ffs/ufs_lookup.c 6.25
SCCS-vsn: sys/ufs/ufs/ufs_lookup.c 6.25

usr/src/sys/kern/vfs_lookup.c
usr/src/sys/ufs/ffs/ufs_lookup.c
usr/src/sys/ufs/ufs/ufs_lookup.c

index d8172dd..5f7aba1 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)vfs_lookup.c        6.24 (Berkeley) %G%
+ *     @(#)vfs_lookup.c        6.25 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -1118,8 +1118,6 @@ dirempty(ip, parentino)
 #define        MINDIRSIZ (sizeof (struct dirtemplate) / 2)
 
        for (off = 0; off < ip->i_size; off += dp->d_reclen) {
 #define        MINDIRSIZ (sizeof (struct dirtemplate) / 2)
 
        for (off = 0; off < ip->i_size; off += dp->d_reclen) {
-               if (dp->d_reclen <= 0)
-                       return (0);
                error = rdwri(UIO_READ, ip, (caddr_t)dp, MINDIRSIZ,
                    off, 1, &count);
                /*
                error = rdwri(UIO_READ, ip, (caddr_t)dp, MINDIRSIZ,
                    off, 1, &count);
                /*
@@ -1128,6 +1126,9 @@ dirempty(ip, parentino)
                 */
                if (error || count != 0)
                        return (0);
                 */
                if (error || count != 0)
                        return (0);
+               /* avoid infinite loops */
+               if (dp->d_reclen <= 0)
+                       return (0);
                /* skip empty entries */
                if (dp->d_ino == 0)
                        continue;
                /* skip empty entries */
                if (dp->d_ino == 0)
                        continue;
index febe481..dabbe74 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)ufs_lookup.c        6.24 (Berkeley) %G%
+ *     @(#)ufs_lookup.c        6.25 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -1118,8 +1118,6 @@ dirempty(ip, parentino)
 #define        MINDIRSIZ (sizeof (struct dirtemplate) / 2)
 
        for (off = 0; off < ip->i_size; off += dp->d_reclen) {
 #define        MINDIRSIZ (sizeof (struct dirtemplate) / 2)
 
        for (off = 0; off < ip->i_size; off += dp->d_reclen) {
-               if (dp->d_reclen <= 0)
-                       return (0);
                error = rdwri(UIO_READ, ip, (caddr_t)dp, MINDIRSIZ,
                    off, 1, &count);
                /*
                error = rdwri(UIO_READ, ip, (caddr_t)dp, MINDIRSIZ,
                    off, 1, &count);
                /*
@@ -1128,6 +1126,9 @@ dirempty(ip, parentino)
                 */
                if (error || count != 0)
                        return (0);
                 */
                if (error || count != 0)
                        return (0);
+               /* avoid infinite loops */
+               if (dp->d_reclen <= 0)
+                       return (0);
                /* skip empty entries */
                if (dp->d_ino == 0)
                        continue;
                /* skip empty entries */
                if (dp->d_ino == 0)
                        continue;
index febe481..dabbe74 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)ufs_lookup.c        6.24 (Berkeley) %G%
+ *     @(#)ufs_lookup.c        6.25 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -1118,8 +1118,6 @@ dirempty(ip, parentino)
 #define        MINDIRSIZ (sizeof (struct dirtemplate) / 2)
 
        for (off = 0; off < ip->i_size; off += dp->d_reclen) {
 #define        MINDIRSIZ (sizeof (struct dirtemplate) / 2)
 
        for (off = 0; off < ip->i_size; off += dp->d_reclen) {
-               if (dp->d_reclen <= 0)
-                       return (0);
                error = rdwri(UIO_READ, ip, (caddr_t)dp, MINDIRSIZ,
                    off, 1, &count);
                /*
                error = rdwri(UIO_READ, ip, (caddr_t)dp, MINDIRSIZ,
                    off, 1, &count);
                /*
@@ -1128,6 +1126,9 @@ dirempty(ip, parentino)
                 */
                if (error || count != 0)
                        return (0);
                 */
                if (error || count != 0)
                        return (0);
+               /* avoid infinite loops */
+               if (dp->d_reclen <= 0)
+                       return (0);
                /* skip empty entries */
                if (dp->d_ino == 0)
                        continue;
                /* skip empty entries */
                if (dp->d_ino == 0)
                        continue;