php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58421 [PATCH] ZTS build, Segfault and Mem. leak when instantiating OAuth class
Submitted: 2008-11-21 07:11 UTC Modified: 2008-11-22 16:37 UTC
From: felipe@php.net Assigned: jawed (profile)
Status: Closed Package: oauth (PECL)
PHP Version: 5_2 CVS-2008-11-21 (dev) OS: Linux
Private report: No CVE-ID: None
 [2008-11-21 07:11 UTC] felipe@php.net
Description:
------------
I've fixed the ZTS build, and the redeclaration of tsrm_ls variable, when using TSRMLS_FETCH_FROM_CTX is used inside SO_METHOD. And when instantiating OAuth class I saw a segfault, because the variable wasn't initialized for the optional argument. Fixing this, I saw a memory leak, because this:
	if(OAUTH(soo_exception_ce)==NULL) {
		OAUTH(soo_exception_ce) = (zend_class_entry *)emalloc(sizeof(zend_class_entry));
	}
...
OAUTH(soo_exception_ce) = zend_register_internal_class_ex(&soo_ex_ce,zend_exception_get_default(TSRMLS_C),NULL TSRMLS_CC);

See the code below. var_dump($x); still needing a fix.


Patch:
http://felipe.ath.cx/diff/oauth-zts-segfault-memleak.diff

Reproduce code:
---------------
<?php

$x = new oauth(1,1); /* segfault + memory leak */
var_dump($x); /* still needing a fix */

Actual result:
--------------
#0  0x00000000 in ?? ()
#1  0x082b6e59 in php_var_dump (struc=0x85ee388, level=1, tsrm_ls=0x84d6050) at /home/felipe/dev/php5_2/ext/standard/var.c:135
#2  0x082b719a in zif_var_dump (ht=1, return_value=0x85f9a08, return_value_ptr=0x0, this_ptr=0x0, return_value_used=0, tsrm_ls=0x84d6050) at /home/felipe/dev/php5_2/ext/standard/var.c:186
#3  0x0838a4a2 in zend_do_fcall_common_helper_SPEC (execute_data=0xbf8d8210, tsrm_ls=0x84d6050) at /home/felipe/dev/php5_2/Zend/zend_vm_execute.h:200


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-11-21 08:03 UTC] felipe@php.net
I've updated the patch, it fixes the class handlers issue too.

http://felipe.ath.cx/diff/oauth-zts-segfault-memleak.diff
 [2008-11-21 18:02 UTC] jawed@php.net
Spoke to felipe regarding some of the details regarding the patch and it will be applied in the next release.
 [2008-11-22 04:46 UTC] jawed@php.net
Felipe,

I modified your patch a bit, namely the placement of the hashtable init but I think I've got the spirit of the patch in place. If you can +1 or -1 the changes I will resolve this bug and plan the next release accordingly.
 [2008-11-22 16:37 UTC] felipe@php.net
It's fine now. :)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC