On Mon, Sep 3, 2012 at 5:50 PM, Jaap Keuter <jaap.keu...@xs4all.nl> wrote:

> Anyone knows what strstr() does with a NULL for a haystack? As far as I
> can tell it's unspecified.


I think you're right. "Undefined/unspecified behavior" usually means a
segfault from my experience. This is true for strstr() in OSX ML.

strstr() apparently does not null-check its parameters in the latest
versions of Linux [1], OSX/Darwin (and probably other Un*x) [2], and
Windows [3]. I couldn't find the Windows source for strstr(), but MSDN
indicates:

strstr and wcsstr do not validate their parameters.


Interestingly, Windows does have an error handler in _mbsstr() for invalid
parameters.

[1]: http://lxr.linux.no/linux+v3.5.3/lib/string.c
[2]: http://www.opensource.apple.com/source/xnu/xnu-792.13.8/libsa/strstr.c
[3]: http://msdn.microsoft.com/en-us/library/z9da80kz.aspx
___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev@wireshark.org>
Archives:    http://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-requ...@wireshark.org?subject=unsubscribe

Reply via email to