Bug #66416 [Asn->Opn]: on PowerPC linux, date() function causes Segmentation fault

From: Date: Tue, 24 Oct 2017 08:08:06 +0000
Subject: Bug #66416 [Asn->Opn]: on PowerPC linux, date() function causes Segmentation fault
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-212225@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66416&edit=1

 ID:                 66416
 Updated by:         kalle@php.net
 Reported by:        lidan at cn dot fujitsu dot com
 Summary:            on PowerPC linux, date() function causes
                     Segmentation fault
-Status:             Assigned
+Status:             Open
 Type:               Bug
 Package:            Date/time related
 Operating System:   Linux
 PHP Version:        master-Git-2014-01-05 (Git)
-Assigned To:        derick
+Assigned To:        
 Block user comment: N
 Private report:     N



Previous Comments:
------------------------------------------------------------------------
[2014-01-05 07:40:13] lidan at cn dot fujitsu dot com

description updated.

------------------------------------------------------------------------
[2014-01-05 07:32:56] lidan at cn dot fujitsu dot com

Description:
------------
OS: linux 3.0.8
Arch:PowerPC
PHP version: 5.5.7
configure: 
./configure --host=powerpc-linux --disable-all CC=powerpc-e500v2-linux-gnuspe-gcc

Problem:
on x86 it is OK. But, on PowerPC it caused segmentation fault.
1.$./sapi/cli/php -r 'date("Y");'
Segmentation Fault

It is because in ext/date/lib/parse_tz.c Line 35:

#if (defined(__APPLE__) || defined(__APPLE_CC__)) && (defined(__BIG_ENDIAN__) ||
defined(__LITTLE_ENDIAN__))
# if defined(__LITTLE_ENDIAN__)
#  undef WORDS_BIGENDIAN
# else
#  if defined(__BIG_ENDIAN__)
#   define WORDS_BIGENDIAN
#  endif
   
PowerPC is big endian, so __BIG_ENDIAN__ is defined. But __APPLE__ or __APPLE_CC__ is not defined.
In result, WORD_BIGENDIAN is not defined.

So, in line 45, timelib_conv_int() used the little endian version. The segmentation fault is caused.

#ifdef WORDS_BIGENDIAN
#define timelib_conv_int(l) (l)
#else
#define timelib_conv_int(l) ((l & 0x000000ff) << 24) + ((l & 0x0000ff00) <<     
+ ((l & 0x00ff0000) >> 8) + ((l & 0xff000000) >> 24)
#endif




Test script:
---------------
./sapi/cli/php -r 'date("Y");'

Expected result:
----------------
2014

Actual result:
--------------
Segmentation Fault


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=66416&edit=1


Thread (5 messages)

« previous php.bugs (#212225) next »