]> granicus.if.org Git - php/commitdiff
Fixed compile warnings.
authorIlia Alshanetsky <iliaa@php.net>
Sun, 4 Jan 2004 20:01:07 +0000 (20:01 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Sun, 4 Jan 2004 20:01:07 +0000 (20:01 +0000)
Fixed crash in crack_closedict();
Switched from zend_error() to php_error_docref();

ext/crack/crack.c

index 1d2e32420b4e39dfe7bd83d6d4026eec011cf623..e16e1c14ac3664b4911bf67a53532034830d49a1 100644 (file)
@@ -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;
        }