Bug #71609 [NEW]: Segmentation fault on ZTS with gethostbyname

From: Date: Tue, 16 Feb 2016 10:36:42 +0000
Subject: Bug #71609 [NEW]: Segmentation fault on ZTS with gethostbyname
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-199257@lists.php.net to get a copy of this message
From:             maroszek at gmx dot net
Operating system: Linux Embedded
PHP version:      7.0.3
Package:          Network related
Bug Type:         Bug
Bug description:Segmentation fault on ZTS with gethostbyname

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 bug report at https://bugs.php.net/bug.php?id=71609&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=71609&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=71609&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=71609&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=71609&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=71609&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=71609&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=71609&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=71609&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=71609&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=71609&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=71609&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=71609&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=71609&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71609&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=71609&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=71609&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=71609&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=71609&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=71609&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=71609&r=mysqlcfg



Thread (3 messages)

« previous php.bugs (#199257) next »