php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71609 Segmentation fault on ZTS with gethostbyname
Submitted: 2016-02-16 10:36 UTC Modified: -
From: maroszek at gmx dot net Assigned:
Status: Closed Package: Network related
PHP Version: 7.0.3 OS: Linux Embedded
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: maroszek at gmx dot net
New email:
PHP Version: OS:

 

 [2016-02-16 10:36 UTC] 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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-03-31 11:40 UTC] 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 UTC] krakjoe@php.net
-Status: Open +Status: Closed
 [2016-03-31 11:40 UTC] 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:47 UTC] maroszek at gmx dot net
Awesome! Thanks!
 [2016-07-20 11:32 UTC] davey@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
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 12:01:29 2024 UTC