Prevent SEGV on corrupted msdos directories (Veo Zhang)

This commit is contained in:
christos 2017-04-28 11:33:00 +00:00
parent 930d24b29b
commit 255de32a23
1 changed files with 3 additions and 3 deletions

View File

@ -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 <sys/cdefs.h>
#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 <stdio.h>
@ -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;