[CDFS] Properly check for legal names in CdIsLegalName()

Up to now, it was working by chance. Indeed, due to the invalid
ASCII check performed before calling FsRtlIsAnsiCharacterLegalHpfs(), the
macro is improperly called and overruns the FsRtlLegalAnsiCharacterArray
buffer. Fortunately, up to now, right after that buffer in kernel binary
there are strings which are more or less consistent with the flags that
are expected by the macro, causing a decent behavior of
FsRtlIsAnsiCharacterLegalHpfs() even for extended ASCII characters
(whereas FsRtlIsAnsiCharacterLegalHpfs() is only designed for ASCII
characters). But this is a totally out of control and wrong behavior.
A single change in the way the kernel was built could have caused the
CDFS driver not to work as previously.

I have made the choice to allow any extended ASCII character as done
for the unicode characters. This is a good compromise to avoid drastic
regressions for users having extended ASCII characters in their CD
file names.

This imports proposed upstream commit 1b6b625641dffb49951e60398e1a9c672318ea71
See pull request https://github.com/Microsoft/Windows-driver-samples/pull/278

CORE-14067
This commit is contained in:
Pierre Schweitzer 2018-08-28 07:48:44 +02:00
parent cdb9f03236
commit 9d0596afe1
No known key found for this signature in database
GPG key ID: 7545556C3D585B0B

View file

@ -410,7 +410,17 @@ Return Value:
Wchar < Add2Ptr( FileName->Buffer, FileName->Length, PWCHAR );
Wchar++) {
#ifndef __REACTOS__
if ((*Wchar < 0xff) &&
#else
//
// Check whether ASCII characters are legal.
// We will consider the rest of the characters
// (extended ASCII and unicode) as legal.
//
if ((*Wchar < 0x80) &&
#endif
!FsRtlIsAnsiCharacterLegalHpfs( *Wchar, FALSE ) &&
(*Wchar != L'"') &&
(*Wchar != L'<') &&