iliaa Sun Jan 4 15:01:08 2004 EDT Modified files: (Branch: PHP_4_3) /php-src/ext/crack crack.c Log: Fixed compile warnings. Fixed crash in crack_closedict(); Switched from zend_error() to php_error_docref(); Index: php-src/ext/crack/crack.c diff -u php-src/ext/crack/crack.c:1.18.8.2 php-src/ext/crack/crack.c:1.18.8.3 --- php-src/ext/crack/crack.c:1.18.8.2 Thu Jun 12 08:37:03 2003 +++ php-src/ext/crack/crack.c Sun Jan 4 15:01:07 2004 @@ -15,7 +15,7 @@ | Authors: Alexander Feldman | +----------------------------------------------------------------------+ */ -/* $Id: crack.c,v 1.18.8.2 2003/06/12 12:37:03 andrey Exp $ */ +/* $Id: crack.c,v 1.18.8.3 2004/01/04 20:01:07 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -29,6 +29,9 @@ #include <packer.h> +extern char * FascistLook(PWDICT *pwp, char *instring); +extern int PWClose(PWDICT *pwp); + ZEND_DECLARE_MODULE_GLOBALS(crack) /* True global resources - no need for thread safety here */ @@ -69,11 +72,16 @@ long resource; if (CRACKG(current_id) != -1) { - zend_error(E_WARNING, "Can not use more than one open dictionary with this implementation of libcrack"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can not use more than one open dictionary with this implementation of libcrack"); return -1; } + + if ((PG(safe_mode) && (!php_checkuid(dictpath, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || php_check_open_basedir(dictpath TSRMLS_CC)) { + return -1; + } + if (NULL == (pwdict = PWOpen(dictpath, "r"))) { - zend_error(E_WARNING, "Unable to open a crack dictionary"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to open a crack dictionary"); return -1; } @@ -156,7 +164,7 @@ if (-1 == (resource = _crack_open_dict(Z_STRVAL_PP(dictpath) TSRMLS_CC))) { RETURN_FALSE; } - + RETURN_RESOURCE(resource); } /* }}} */ @@ -184,6 +192,10 @@ break; } + if (id < 1) { + RETURN_FALSE; + } + ZEND_FETCH_RESOURCE(pwdict, PWDICT *, dictionary, id, "cracklib dictionary", le_crack); if (CRACKG(current_id) == id) { CRACKG(current_id) = -1; @@ -218,7 +230,6 @@ if (zend_get_parameters_ex(2, &dictionary, &password) == FAILURE) { RETURN_FALSE; } - id = -1; break; default: WRONG_PARAM_COUNT; @@ -256,7 +267,7 @@ } if (NULL == CRACKG(last_message)) { - zend_error(E_WARNING, "No obscure checks in this session"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "No obscure checks in this session"); RETURN_FALSE; }
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php