From fb9ce4aaa20109e857cc42c974f5bc59be347379 Mon Sep 17 00:00:00 2001 From: Pierre Joye Date: Tue, 23 Feb 2010 17:26:49 +0000 Subject: [PATCH] - return *0/*1 on failure instead of FALSE, to avoid possible issues with bad user code --- ext/standard/crypt.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/ext/standard/crypt.c b/ext/standard/crypt.c index 5123d8ff4a6..a89fd5a10fd 100644 --- a/ext/standard/crypt.c +++ b/ext/standard/crypt.c @@ -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); }