[Patch]: NUL and other special names
Tue Jun 1 22:28:00 GMT 2004
On Tue, Jun 01, 2004 at 06:11:55PM -0400, Pierre A. Humblet wrote:
>Christopher Faylor wrote:
>> On Mon, May 31, 2004 at 06:46:11PM -0400, Pierre A. Humblet wrote:
>> >This patch prevents NtCreateFile from creating files with special
>> >names such as NUL.
>> >Because this needs to be checked very often, I tried to code it
>> >efficiently with a binary search (it can perhaps be reused elsewhere).
>> >The new function is_special_name() overlaps with special_name(),
>> >although there are small differences (it was designed from tests
>> >on XP Home Ed). Perhaps these two can be merged one day.
>> Haven't we already done a "GetFileAttributes" on the path by the time
>> it reaches the NtCreateFile? If so, couldn't we just avoid trying to
>> create a file which has "bad" attributes?
>Yes, we have done a "GetFileAttributes". I just checked the values.
>For AUX, CON, COMx, LPTx, NUL and PRN, the attribute is 0x20,
>For conin$, conout$ and clock$ it is FFFFFFFF
>So we could filter on those values and only test for special names
>Is that what you meant?
I was hoping there might be more state available than that. Oh well.
Is the GetFileType call any better?
I keep thinking that there is a layer of translation that we're missing
here and we should be somehow using an enumeration that the OS provides
rather than coming up with our own table.
More information about the Cygwin-patches