do not expand in degenerate cases
[unix-history] / usr / src / sbin / fsck / dir.c
index 09fe295..02f4119 100644 (file)
@@ -16,7 +16,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)dir.c      5.15 (Berkeley) %G%";
+static char sccsid[] = "@(#)dir.c      5.16 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -455,7 +455,7 @@ expanddir(dp, name)
        char *cp, firstblk[DIRBLKSIZ];
 
        lastbn = lblkno(&sblock, dp->di_size);
        char *cp, firstblk[DIRBLKSIZ];
 
        lastbn = lblkno(&sblock, dp->di_size);
-       if (lastbn >= NDADDR - 1)
+       if (lastbn >= NDADDR - 1 || dp->di_db[lastbn] == 0 || dp->di_size == 0)
                return (0);
        if ((newblk = allocblk(sblock.fs_frag)) == 0)
                return (0);
                return (0);
        if ((newblk = allocblk(sblock.fs_frag)) == 0)
                return (0);