Bug #71609 [Com]: Segmentation fault on ZTS with gethostbyname
Edit report at https://bugs.php.net/bug.php?id=71609&edit=1
ID: 71609
Comment by: maroszek at gmx dot net
Reported by: maroszek at gmx dot net
Summary: Segmentation fault on ZTS with gethostbyname
Status: Closed
Type: Bug
Package: Network related
Operating System: Linux Embedded
PHP Version: 7.0.3
Block user comment: N
Private report: N
New Comment:
Awesome! Thanks!
Previous Comments:
------------------------------------------------------------------------
[2016-03-31 11:40:20] krakjoe@php.net
Automatic comment on behalf of krakjoe
Revision: http://git.php.net/?p=php-src.git;a=commit;h=233115ea236fd1aa258e8b733d3855d1261fba8b
Log: fix #71609: Segmentation fault on ZTS with gethostbyname
------------------------------------------------------------------------
[2016-03-31 11:40:04] krakjoe@php.net
Automatic comment on behalf of krakjoe
Revision: http://git.php.net/?p=php-src.git;a=commit;h=233115ea236fd1aa258e8b733d3855d1261fba8b
Log: fix #71609: Segmentation fault on ZTS with gethostbyname
------------------------------------------------------------------------
[2016-02-16 10:36:37] maroszek at gmx dot net
Description:
------------
System: Custom Buildroot with BusyBox and uClibc
The function above (and maybe some more) are not threadsafe
http://linux.die.net/man/3/gethostbyname
Affected are at least 7 files:
php-7.0.3\ext\sockets\sockaddr_conv.c
php-7.0.3\ext\sockets\sockets.c
php-7.0.3\ext\standard\basic_functions.c
php-7.0.3\ext\standard\dns.c
php-7.0.3\main\fastcgi.c
php-7.0.3\main\network.c
php-7.0.3\win32\sendmail.c
A nice quote from network.c: (Btw i loved this comment!)
/* XXX NOT THREAD SAFE (is safe under win32) */
if(strlen(host) > MAXFQDNLEN) {
host_info = NULL;
errno = E2BIG;
} else {
host_info = gethostbyname(host);
}
The question is if patches that move from gethostbyname to gethostbyname_r would be welcome?
If yes: Are any platform specifics i should take care of?
Test script:
---------------
Just use arbitary network functions which resolv DNS names. It will crash eventually.
Expected result:
----------------
No crash.
Actual result:
--------------
I'll hand one in later if required.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71609&edit=1
Thread (3 messages)