php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66416 on PowerPC linux, date() function causes Segmentation fault
Submitted: 2014-01-05 07:32 UTC Modified: 2017-10-24 08:08 UTC
Votes:3
Avg. Score:5.0 ± 0.0
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:2 (66.7%)
From: lidan at cn dot fujitsu dot com Assigned:
Status: Open Package: Date/time related
PHP Version: master-Git-2014-01-05 (Git) OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2014-01-05 07:32 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-01-05 07:40 UTC] lidan at cn dot fujitsu dot com
-Summary: on PowerPC linux, date() functions calls Segmentation fault +Summary: on PowerPC linux, date() function causes Segmentation fault
 [2014-01-05 07:40 UTC] lidan at cn dot fujitsu dot com
description updated.
 [2014-01-19 14:51 UTC] felipe@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: derick
 [2017-10-24 08:08 UTC] kalle@php.net
-Status: Assigned +Status: Open -Assigned To: derick +Assigned To:
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Jul 23 22:01:28 2019 UTC