--- embedaddon/php/ext/session/mod_user.c 2012/02/21 23:48:01 1.1.1.1 +++ embedaddon/php/ext/session/mod_user.c 2014/06/15 20:03:55 1.1.1.4 @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2012 The PHP Group | + | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mod_user.c,v 1.1.1.1 2012/02/21 23:48:01 misho Exp $ */ +/* $Id: mod_user.c,v 1.1.1.4 2014/06/15 20:03:55 misho Exp $ */ #include "php.h" #include "php_session.h" @@ -62,15 +62,10 @@ static zval *ps_call_handler(zval *func, int argc, zva return retval; } -#define STDVARS1 \ - zval *retval; \ +#define STDVARS \ + zval *retval = NULL; \ int ret = FAILURE -#define STDVARS \ - STDVARS1; \ - char *mdata = PS_GET_MOD_DATA(); \ - if (!mdata) { return FAILURE; } - #define PSF(a) PS(mod_user_names).name.ps_##a #define FINISH \ @@ -84,32 +79,48 @@ static zval *ps_call_handler(zval *func, int argc, zva PS_OPEN_FUNC(user) { zval *args[2]; - static char dummy = 0; - STDVARS1; + STDVARS; + + if (PSF(open) == NULL) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, + "user session functions not defined"); + + return FAILURE; + } SESS_ZVAL_STRING((char*)save_path, args[0]); SESS_ZVAL_STRING((char*)session_name, args[1]); retval = ps_call_handler(PSF(open), 2, args TSRMLS_CC); - if (retval) { - /* This is necessary to fool the session module. Yes, it's safe to - * use a static. Neither mod_user nor the session module itself will - * ever touch this pointer. It could be set to 0xDEADBEEF for all the - * difference it makes, but for the sake of paranoia it's set to some - * valid value. */ - PS_SET_MOD_DATA(&dummy); - } + PS(mod_user_implemented) = 1; FINISH; } PS_CLOSE_FUNC(user) { - STDVARS1; + zend_bool bailout = 0; + STDVARS; - retval = ps_call_handler(PSF(close), 0, NULL TSRMLS_CC); + if (!PS(mod_user_implemented)) { + /* already closed */ + return SUCCESS; + } - PS_SET_MOD_DATA(NULL); + zend_try { + retval = ps_call_handler(PSF(close), 0, NULL TSRMLS_CC); + } zend_catch { + bailout = 1; + } zend_end_try(); + + PS(mod_user_implemented) = 0; + + if (bailout) { + if (retval) { + zval_ptr_dtor(&retval); + } + zend_bailout(); + } FINISH; }