artulab
projects
/
openbsd
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
f2643dc
)
Avoid the possibility of accessing an array out of bounds.
author
jsg
<jsg@openbsd.org>
Tue, 27 Jun 2017 12:10:21 +0000
(12:10 +0000)
committer
jsg
<jsg@openbsd.org>
Tue, 27 Jun 2017 12:10:21 +0000
(12:10 +0000)
Found with cppcheck. ok krw@
sbin/fsck_msdos/dir.c
patch
|
blob
|
history
diff --git
a/sbin/fsck_msdos/dir.c
b/sbin/fsck_msdos/dir.c
index
5ab153d
..
7397e57
100644
(file)
--- a/
sbin/fsck_msdos/dir.c
+++ b/
sbin/fsck_msdos/dir.c
@@
-1,4
+1,4
@@
-/* $OpenBSD: dir.c,v 1.3
0 2015/12/10 17:26:59 mmcc Exp $
*/
+/* $OpenBSD: dir.c,v 1.3
1 2017/06/27 12:10:21 jsg Exp $
*/
/* $NetBSD: dir.c,v 1.11 1997/10/17 11:19:35 ws Exp $ */
/*
@@
-593,6
+593,8
@@
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 (k < 0)
+ k = 0;
if (dirent.name[k] != '\0')
k++;
if (dirent.name[0] == SLOT_E5)