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

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) {