php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58461 compact_underscores_convert segfaults with 0 length string
Submitted: 2008-12-16 17:44 UTC Modified: 2013-11-11 11:00 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: web-php-bugs at sklar dot com Assigned: derick (profile)
Status: Closed Package: translit (PECL)
PHP Version: 5_2 CVS-2008-12-16 (dev) OS: Linux
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.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: web-php-bugs at sklar dot com
New email:
PHP Version: OS:

 

 [2008-12-16 17:44 UTC] web-php-bugs at sklar dot com
Description:
------------
When transliterate() is called with a 0-length string, the compact_underscores_convert filter segfaults on line 36 because out_idx is 0, so

tmp_out[out_idx - 1]

is out of bounds.


(This could be an issue with other filters, too.)



Reproduce code:
---------------
$s = transliterate('', array('compact_underscores'), 'utf-8','ascii');

Expected result:
----------------
$s is set to ''


Actual result:
--------------
Segmentation fault


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-03-09 16:24 UTC] tech-php at sklar dot com
Patch that fixes the problem:

*** data/compact_underscores.c.orig	2010-03-09 15:12:25.000000000 -0500
--- data/compact_underscores.c	2010-03-09 16:16:03.000000000 -0500
***************
*** 33,39 ****
  			count = 0;
  		}
  	}
! 	while (tmp_out[out_idx - 1] == (unsigned short) '_') {
  		out_idx--;
  	}
  	*out_length = out_idx;
--- 33,39 ----
  			count = 0;
  		}
  	}
! 	while ((out_idx > 0) && (tmp_out[out_idx - 1] == (unsigned short) '_')) {
  		out_idx--;
  	}
  	*out_length = out_idx;
 [2013-11-11 10:59 UTC] derick@php.net
Automatic comment from SVN on behalf of derick
Revision: http://svn.php.net/viewvc/?view=revision&revision=332106
Log: - Fixed bug #58461: compact_underscores_convert segfaults with 0 length string.
  (Patch by David Sklar)
 [2013-11-11 11:00 UTC] derick@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: derick
 [2013-11-11 11:00 UTC] derick@php.net
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Nov 04 18:01:28 2024 UTC