kernel32: Avoid two potential buffer overflows of cStr in create_hardware_branch.

Alexandre Julliard julliard at winehq.org
Sun Feb 12 03:20:32 CST 2017


Gerald Pfeifer <gerald at pfeifer.com> writes:

> On Tue, 11 Oct 2016, Sebastian Lackner wrote:
>>> According to that man page
>>> 
>>>   Warning: applications should avoid any dependence on the  size  of  the
>>>   d_name  field.  POSIX defines it as char d_name[], a character array of
>>>   unspecified size, with at most NAME_MAX characters preceding the termi-
>>>   nating null byte ('\0').
>>> 
>>> so we should be fine, shouldn't we?
>> NAME_MAX is only used at a few places, so not sure if it works on all 
>> platforms.
>
> In my experience, if it works on a Linux distro like openSUSE and
> FreeBSD, it tends to work on all platforms Wine supports. ;-)
>
> The better argument probably is that NAME_MAX is used in ntdll/directory.c
> already.

Not really, only in a very system-specific case.

The existing sizes are fine, but if you really want to fix that code,
you should check for overflow and simply ignore names that don't match
what we expect.

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list