From: Ilia Alshanetsky Date: Sun, 4 Jan 2004 20:01:07 +0000 (+0000) Subject: Fixed compile warnings. X-Git-Tag: php-4.3.5RC1~12 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7f529a836158de935347e7db523426634a2a02ee;p=php Fixed compile warnings. Fixed crash in crack_closedict(); Switched from zend_error() to php_error_docref(); --- 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 +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; }