Avoid out of boundary access when checking invalid long filenames.

Obtained from:	OpenBSD (dir.c,v 1.25)
MFC after:	3 days
This commit is contained in:
Xin LI 2019-06-11 22:21:29 +00:00
parent 77a0144145
commit bf6ed41692
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=348967

View File

@ -629,6 +629,15 @@ readDosDirSection(int f, struct bootblock *boot, struct fatEntry *fat,
vallfn = NULL;
}
lidx = *p & LRNOMASK;
if (lidx == 0) {
pwarn("invalid long name\n");
if (!invlfn) {
invlfn = vallfn;
invcl = valcl;
}
vallfn = NULL;
continue;
}
t = longName + --lidx * 13;
for (k = 1; k < 11 && t < longName +
sizeof(longName); k += 2) {