- return *0/*1 on failure instead of FALSE, to avoid possible issues with bad user code

This commit is contained in:
Pierre Joye 2010-02-23 17:26:49 +00:00
parent 5cbece0a8e
commit fb9ce4aaa2

View File

@ -198,7 +198,11 @@ PHP_FUNCTION(crypt)
crypt_res = php_sha512_crypt_r(str, salt, output, needed);
if (!crypt_res) {
RETVAL_FALSE;
if (salt[0]=='*' && salt[1]=='0') {
RETVAL_STRING("*1", 1);
} else {
RETVAL_STRING("*0", 1);
}
} else {
RETVAL_STRING(output, 1);
}
@ -217,7 +221,11 @@ PHP_FUNCTION(crypt)
crypt_res = php_sha256_crypt_r(str, salt, output, needed);
if (!crypt_res) {
RETVAL_FALSE;
if (salt[0]=='*' && salt[1]=='0') {
RETVAL_STRING("*1", 1);
} else {
RETVAL_STRING("*0", 1);
}
} else {
RETVAL_STRING(output, 1);
}
@ -238,7 +246,11 @@ PHP_FUNCTION(crypt)
crypt_res = php_crypt_blowfish_rn(str, salt, output, sizeof(output));
if (!crypt_res) {
RETVAL_FALSE;
if (salt[0]=='*' && salt[1]=='0') {
RETVAL_STRING("*1", 1);
} else {
RETVAL_STRING("*0", 1);
}
} else {
RETVAL_STRING(output, 1);
}
@ -250,7 +262,11 @@ PHP_FUNCTION(crypt)
crypt_res = _crypt_extended_r(str, salt, &buffer);
if (!crypt_res) {
RETURN_FALSE;
if (salt[0]=='*' && salt[1]=='0') {
RETURN_STRING("*1", 1);
} else {
RETURN_STRING("*0", 1);
}
} else {
RETURN_STRING(crypt_res, 1);
}
@ -270,7 +286,11 @@ PHP_FUNCTION(crypt)
# endif
crypt_res = crypt_r(str, salt, &buffer);
if (!crypt_res) {
RETURN_FALSE;
if (salt[0]=='*' && salt[1]=='0') {
RETURN_STRING("*1", 1);
} else {
RETURN_STRING("*0", 1);
}
} else {
RETURN_STRING(crypt_res, 1);
}