php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35575 gettext call segfaults with memory allocation error
Submitted: 2005-12-06 22:37 UTC Modified: 2005-12-07 20:00 UTC
From: tokul at users dot sourceforge dot net Assigned:
Status: Not a bug Package: Gettext related
PHP Version: 5CVS-2005-12-06 (snap) OS: OpenBSD 3.8
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: tokul at users dot sourceforge dot net
New email:
PHP Version: OS:

 

 [2005-12-06 22:37 UTC] tokul at users dot sourceforge dot net
Description:
------------
If gettext extension manages to locate .mo file, script breaks with memory allocation error.

php compiled with --disable-all --enable-cli --with-gettext

same error in 5.0.4 and 5.1.1.

do you need php.core file?

Reproduce code:
---------------
bindtextdomain('test','./');
textdomain('test');
setlocale(LC_ALL, 'ru_RU.UTF-8');
putenv('LC_ALL=ru_RU.UTF-8');
echo _("Test");

Expected result:
----------------
Test

Actual result:
--------------
tail of kdump
-----
15066 php      CALL  mmap(0,0x4395ef38,0x1,0x2,0x3,0,0,0)
15066 php      RET   mmap -1 errno 12 Cannot allocate memory
15066 php      CALL  mmap(0,0x4395f000,0x3,0x1002,0xffffffff,0,0,0)
15066 php      RET   mmap -1 errno 12 Cannot allocate memory
15066 php      PSIG  SIGSEGV SIG_DFL code 1 addr=0x58e64 trapno=1
15066 php      NAMI  "php.core"
-----

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-12-06 22:48 UTC] tony2001@php.net
JFYI: the reproduce script works perfectly fine on Linux and outputs:
Test
 [2005-12-07 09:34 UTC] tokul at users dot sourceforge dot net
It is specific to OpenBSD. They rewrote malloc code in v.3.8. You need ru/LC_MESSAGES/test.mo file in order to reproduce it. I think any compiled gettext translation file can be used for test.mo.

I can reproduce problem with standard gettext library distributed with OpenBSD. gettext v.0.10.40.

If php is compiled against GNU gettext 0.14.3, script works as expected without segfaults.

Backtrace
----
#0  0x00085e74 in ?? ()
#1  0xe92d2eb8 in ?? ()
#2  0x00000001 in ?? ()
#3  0x00000000 in ?? ()
#4  0x0cfbcc3e in _nl_find_domain () from /usr/local/lib/libintl.so.1.1
Previous frame inner to this frame (corrupt stack?)
----

I'll try contacting OpenBSD devels.
 [2005-12-07 09:39 UTC] tony2001@php.net
If it happens because OpenBSD developers rewrote malloc()'s code - report that problem to them.
 [2005-12-07 20:00 UTC] tokul at users dot sourceforge dot net
OpenBSD rewrote malloc in order to make it secure.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC