1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-12-30 05:40:06 +00:00
freebsd-ports/security/pecl-crack/files/patch-modern-api
Mikhail Teterin 97baea514d Remove the hunk replacing the original argument-parsing. Though the
old code is ugly, it is correct and replacement is thus not warranted.
2015-04-14 16:24:00 +00:00

128 lines
3.5 KiB
Plaintext

--- crack.c 2005-09-21 05:00:06.000000000 -0400
+++ crack.c 2015-04-14 12:19:37.774605000 -0400
@@ -32,5 +32,5 @@
#include "php_crack.h"
-#include "libcrack/src/cracklib.h"
+#include <packer.h>
/* True global resources - no need for thread safety here */
@@ -39,5 +39,5 @@
/* {{{ crack_functions[]
*/
-function_entry crack_functions[] = {
+zend_function_entry crack_functions[] = {
PHP_FE(crack_opendict, NULL)
PHP_FE(crack_closedict, NULL)
@@ -91,42 +91,7 @@
/* {{{ php_crack_checkpath
*/
-static int php_crack_checkpath(char* path TSRMLS_DC)
+static int php_crack_checkpath(const char* path TSRMLS_DC)
{
- char *filename;
- int filename_len;
- int result = SUCCESS;
-
- if (PG(safe_mode)) {
- filename_len = strlen(path) + 10;
- filename = (char *) emalloc(filename_len);
- if (NULL == filename) {
- return FAILURE;
- }
-
- memset(filename, '\0', filename_len);
- strcpy(filename, path);
- strcat(filename, ".pwd");
- if (!php_checkuid(filename, "r", CHECKUID_CHECK_FILE_AND_DIR)) {
- efree(filename);
- return FAILURE;
- }
-
- memset(filename, '\0', filename_len);
- strcpy(filename, path);
- strcat(filename, ".pwi");
- if (!php_checkuid(filename, "r", CHECKUID_CHECK_FILE_AND_DIR)) {
- efree(filename);
- return FAILURE;
- }
-
- memset(filename, '\0', filename_len);
- strcpy(filename, path);
- strcat(filename, ".hwm");
- if (!php_checkuid(filename, "r", CHECKUID_CHECK_FILE_AND_DIR)) {
- efree(filename);
- return FAILURE;
- }
- }
-
+
if (php_check_open_basedir(path TSRMLS_CC)) {
return FAILURE;
@@ -155,7 +120,6 @@
{
if ((-1 == CRACKG(default_dict)) && (NULL != CRACKG(default_dictionary))) {
- CRACKLIB_PWDICT *pwdict;
- printf("trying to open: %s\n", CRACKG(default_dictionary));
- pwdict = cracklib_pw_open(CRACKG(default_dictionary), "r");
+ PWDICT *pwdict;
+ pwdict = PWOpen(CRACKG(default_dictionary), "r");
if (NULL != pwdict) {
ZEND_REGISTER_RESOURCE(return_value, pwdict, le_crack);
@@ -172,8 +136,8 @@
static void php_crack_module_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
{
- CRACKLIB_PWDICT *pwdict = (CRACKLIB_PWDICT *) rsrc->ptr;
+ PWDICT *pwdict = (PWDICT *) rsrc->ptr;
if (pwdict != NULL) {
- cracklib_pw_close(pwdict);
+ PWClose(pwdict);
}
}
@@ -245,5 +209,5 @@
char *path;
int path_len;
- CRACKLIB_PWDICT *pwdict;
+ PWDICT *pwdict;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &path, &path_len) == FAILURE) {
@@ -255,5 +219,5 @@
}
- pwdict = cracklib_pw_open(path, "r");
+ pwdict = PWOpen(path, "r");
if (NULL == pwdict) {
#if ZEND_MODULE_API_NO >= 20021010
@@ -276,5 +240,5 @@
zval *dictionary = NULL;
int id = -1;
- CRACKLIB_PWDICT *pwdict;
+ PWDICT *pwdict;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|r", &dictionary)) {
@@ -293,5 +257,5 @@
}
}
- ZEND_FETCH_RESOURCE(pwdict, CRACKLIB_PWDICT *, &dictionary, id, "crack dictionary", le_crack);
+ ZEND_FETCH_RESOURCE(pwdict, PWDICT *, &dictionary, id, "crack dictionary", le_crack);
if (NULL == dictionary) {
@@ -319,5 +283,5 @@
int gecos_len;
char *message;
- CRACKLIB_PWDICT *pwdict;
+ PWDICT *pwdict;
int id = -1;
@@ -344,7 +337,7 @@
}
}
- ZEND_FETCH_RESOURCE(pwdict, CRACKLIB_PWDICT *, &dictionary, id, "crack dictionary", le_crack);
+ ZEND_FETCH_RESOURCE(pwdict, PWDICT *, &dictionary, id, "crack dictionary", le_crack);
- message = cracklib_fascist_look_ex(pwdict, password, username, gecos);
+ message = FascistLookUser(pwdict, password, username, gecos);
if (NULL == message) {