This is the mail archive of the cygwin-patches mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix possible segmentation fault in strnstr() on 64-bit systems


On 2017-09-13 10:44, Johannes Schindelin wrote:
> As of f22054c94d (Modify strnstr.c., 2017-08-30), the strnstr()
> implementation was replaced by a version that segfaults (at least
> sometimes) on 64-bit systems.
> 
> The reason: the new implementation uses memmem(), and the prototype of
> memmem() is missing because the _GNU_SOURCE constant is not defined
> before including <string.h>. As a consequence its return type defaults
> to int (and GCC spits out a warning).
> 
> On 64-bit systems, the int data type is too small, though, to hold a
> full char *, hence the upper 32-bit are cut off and bad things happen
> due to a bogus pointer being used to access memory.
> 
> Reported as https://github.com/Alexpux/MINGW-packages/issues/2879 in
> the MSYS2 project.

As this is part of newlib, the proper place for this is on the newlib
list.  Others have already proposed similar patches, so please feel free
to follow the discussion there.

-- 
Yaakov

Attachment: signature.asc
Description: OpenPGP digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]