diff options
author | Ilia Alshanetsky <iliaa@php.net> | 2004-01-04 20:01:07 +0000 |
---|---|---|
committer | Ilia Alshanetsky <iliaa@php.net> | 2004-01-04 20:01:07 +0000 |
commit | 7f529a836158de935347e7db523426634a2a02ee (patch) | |
tree | ef36f28bfcc1cffee20163b5779f142fe6e51ee2 | |
parent | 9a0060e27c313cb1c163b14cd69c4aeb4069d73b (diff) | |
download | php-git-7f529a836158de935347e7db523426634a2a02ee.tar.gz |
Fixed compile warnings.
Fixed crash in crack_closedict();
Switched from zend_error() to php_error_docref();
-rw-r--r-- | ext/crack/crack.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/ext/crack/crack.c b/ext/crack/crack.c index 1d2e32420b..e16e1c14ac 100644 --- a/ext/crack/crack.c +++ b/ext/crack/crack.c @@ -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 _crack_open_dict(char *dictpath TSRMLS_DC) 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 @@ ZEND_FUNCTION(crack_opendict) if (-1 == (resource = _crack_open_dict(Z_STRVAL_PP(dictpath) TSRMLS_CC))) { RETURN_FALSE; } - + RETURN_RESOURCE(resource); } /* }}} */ @@ -184,6 +192,10 @@ ZEND_FUNCTION(crack_closedict) 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 @@ ZEND_FUNCTION(crack_check) if (zend_get_parameters_ex(2, &dictionary, &password) == FAILURE) { RETURN_FALSE; } - id = -1; break; default: WRONG_PARAM_COUNT; @@ -256,7 +267,7 @@ ZEND_FUNCTION(crack_getlastmessage) } 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; } |