diff --git a/sbin/fsck_msdos/dir.c b/sbin/fsck_msdos/dir.c index 7dfd06f21b33..60be7af1b405 100644 --- a/sbin/fsck_msdos/dir.c +++ b/sbin/fsck_msdos/dir.c @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.28 2016/03/07 14:47:25 christos Exp $ */ +/* $NetBSD: dir.c,v 1.29 2017/04/28 11:33:00 christos Exp $ */ /* * Copyright (C) 1995, 1996, 1997 Wolfgang Solfrank @@ -30,7 +30,7 @@ #include #ifndef lint -__RCSID("$NetBSD: dir.c,v 1.28 2016/03/07 14:47:25 christos Exp $"); +__RCSID("$NetBSD: dir.c,v 1.29 2017/04/28 11:33:00 christos Exp $"); #endif /* not lint */ #include @@ -623,7 +623,7 @@ readDosDirSection(int f, struct bootblock *boot, struct fatEntry *fat, dirent.name[8] = '\0'; for (k = 7; k >= 0 && dirent.name[k] == ' '; k--) dirent.name[k] = '\0'; - if (dirent.name[k] != '\0') + if (k < 0 || dirent.name[k] != '\0') k++; if (dirent.name[0] == SLOT_E5) dirent.name[0] = 0xe5;