summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Orlitzky <michael@orlitzky.com>2015-11-09 10:49:10 -0500
committerNikita Popov <nikic@php.net>2016-03-03 17:12:57 +0100
commit08fce8e2c5de358b9552adf94302f0f798a48d89 (patch)
tree185511ecd3e1beea40860d030296308982f95673
parentbdd578fcbbd0d75f76a2775dea8c8db1cc47b1f5 (diff)
downloadphp-git-08fce8e2c5de358b9552adf94302f0f798a48d89.tar.gz
ext/standard/config.m4: fix crypt() test segfaults in >=glibc-2.17.
Starting with glibc-2.17, the crypt() function will report an EINVAL and return NULL when the format of the "salt" parameter is invalid. The current tests for crypt() pass its result to strcmp(), causing segfaults when the value returned from crypt() is NULL. This commit modifies the test programs to exit with failure when crypt() returns NULL. Reference: https://bugs.gentoo.org/show_bug.cgi?id=518964
-rw-r--r--ext/standard/config.m418
1 files changed, 12 insertions, 6 deletions
diff --git a/ext/standard/config.m4 b/ext/standard/config.m4
index d328979c59..2a4218b370 100644
--- a/ext/standard/config.m4
+++ b/ext/standard/config.m4
@@ -71,7 +71,8 @@ AC_CACHE_CHECK(for standard DES crypt, ac_cv_crypt_des,[
main() {
#if HAVE_CRYPT
- exit (strcmp((char *)crypt("rasmuslerdorf","rl"),"rl.3StKT.4T8M"));
+ char* encrypted = crypt("rasmuslerdorf","rl");
+ exit (!encrypted || strcmp(encrypted,"rl.3StKT.4T8M"));
#else
exit(0);
#endif
@@ -95,7 +96,8 @@ AC_CACHE_CHECK(for extended DES crypt, ac_cv_crypt_ext_des,[
main() {
#if HAVE_CRYPT
- exit (strcmp((char *)crypt("rasmuslerdorf","_J9..rasm"),"_J9..rasmBYk8r9AiWNc"));
+ char* encrypted = crypt("rasmuslerdorf","_J9..rasm");
+ exit (!encrypted || strcmp(encrypted,"_J9..rasmBYk8r9AiWNc"));
#else
exit(0);
#endif
@@ -128,7 +130,8 @@ main() {
salt[12]='\0';
strcpy(answer,salt);
strcat(answer,"rISCgZzpwk3UhDidwXvin0");
- exit (strcmp((char *)crypt("rasmuslerdorf",salt),answer));
+ char* encrypted = crypt("rasmuslerdorf",salt);
+ exit (!encrypted || strcmp(encrypted,answer));
#else
exit(0);
#endif
@@ -158,7 +161,8 @@ main() {
strcat(salt,"rasmuslerd............");
strcpy(answer,salt);
strcpy(&answer[29],"nIdrcHdxcUxWomQX9j6kvERCFjTg7Ra");
- exit (strcmp((char *)crypt("rasmuslerdorf",salt),answer));
+ char* encrypted = crypt("rasmuslerdorf",salt);
+ exit (!encrypted || strcmp(encrypted,answer));
#else
exit(0);
#endif
@@ -187,7 +191,8 @@ main() {
strcpy(salt,"\$6\$rasmuslerdorf\$");
strcpy(answer, salt);
strcat(answer, "EeHCRjm0bljalWuALHSTs1NB9ipEiLEXLhYeXdOpx22gmlmVejnVXFhd84cEKbYxCo.XuUTrW.RLraeEnsvWs/");
- exit (strcmp((char *)crypt("rasmuslerdorf",salt),answer));
+ char* encrypted = crypt("rasmuslerdorf",salt);
+ exit (!encrypted || strcmp(encrypted,answer));
#else
exit(0);
#endif
@@ -216,7 +221,8 @@ main() {
strcpy(salt,"\$5\$rasmuslerdorf\$");
strcpy(answer, salt);
strcat(answer, "cFAm2puLCujQ9t.0CxiFIIvFi4JyQx5UncCt/xRIX23");
- exit (strcmp((char *)crypt("rasmuslerdorf",salt),answer));
+ char* encrypted = crypt("rasmuslerdorf",salt);
+ exit (!encrypted || strcmp(encrypted,answer));
#else
exit(0);