You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by jo...@apache.org on 2012/06/06 15:06:02 UTC
svn commit: r1346872 - /apr/apr-util/branches/1.5.x/crypto/apr_md5.c
Author: jorton
Date: Wed Jun 6 13:06:02 2012
New Revision: 1346872
URL: http://svn.apache.org/viewvc?rev=1346872&view=rev
Log:
Merge r779396 from trunk:
* Failing crypt can cause a segfault. Check for result of crypt to avoid this.
PR: 47272
Submitted by: Arkadiusz Miskiewicz <arekm pld-linux.org>
Reviewed by: rpluem (trunk commit)
Modified:
apr/apr-util/branches/1.5.x/crypto/apr_md5.c
Modified: apr/apr-util/branches/1.5.x/crypto/apr_md5.c
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.5.x/crypto/apr_md5.c?rev=1346872&r1=1346871&r2=1346872&view=diff
==============================================================================
--- apr/apr-util/branches/1.5.x/crypto/apr_md5.c (original)
+++ apr/apr-util/branches/1.5.x/crypto/apr_md5.c Wed Jun 6 13:06:02 2012
@@ -721,6 +721,9 @@ APU_DECLARE(apr_status_t) apr_password_v
CRYPTD buffer;
crypt_pw = crypt_r(passwd, hash, &buffer);
+ if (!crypt_pw) {
+ return APR_EMISMATCH;
+ }
apr_cpystrn(sample, crypt_pw, sizeof(sample) - 1);
#elif defined(CRYPT_R_STRUCT_CRYPT_DATA)
struct crypt_data buffer;
@@ -732,6 +735,9 @@ APU_DECLARE(apr_status_t) apr_password_v
*/
memset(&buffer, 0, sizeof(buffer));
crypt_pw = crypt_r(passwd, hash, &buffer);
+ if (!crypt_pw) {
+ return APR_EMISMATCH;
+ }
apr_cpystrn(sample, crypt_pw, sizeof(sample) - 1);
#else
/* Do a bit of sanity checking since we know that crypt_r()
@@ -748,6 +754,10 @@ APU_DECLARE(apr_status_t) apr_password_v
*/
crypt_mutex_lock();
crypt_pw = crypt(passwd, hash);
+ if (!crypt_pw) {
+ crypt_mutex_unlock();
+ return APR_EMISMATCH;
+ }
apr_cpystrn(sample, crypt_pw, sizeof(sample) - 1);
crypt_mutex_unlock();
#endif