CVE-2013-4122.patch 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. From dedad73e5e7a75d01a5f3d5a6702ab8ccd2ff40d Mon Sep 17 00:00:00 2001
  2. From: mancha <mancha1@hush.com>
  3. Date: Thu, 11 Jul 2013 09:08:07 +0000
  4. Subject: Handle NULL returns from glibc 2.17+ crypt()
  5. Starting with glibc 2.17 (eglibc 2.17), crypt() fails with EINVAL
  6. (w/ NULL return) if the salt violates specifications. Additionally,
  7. on FIPS-140 enabled Linux systems, DES/MD5-encrypted passwords
  8. passed to crypt() fail with EPERM (w/ NULL return).
  9. When using glibc's crypt(), check return value to avoid a possible
  10. NULL pointer dereference.
  11. Patch by mancha1@hush.com.
  12. ---
  13. diff --git a/pwcheck/pwcheck_getpwnam.c b/pwcheck/pwcheck_getpwnam.c
  14. index 4b34222..400289c 100644
  15. --- a/pwcheck/pwcheck_getpwnam.c
  16. +++ b/pwcheck/pwcheck_getpwnam.c
  17. @@ -32,6 +32,7 @@ char *userid;
  18. char *password;
  19. {
  20. char* r;
  21. + char* crpt_passwd;
  22. struct passwd *pwd;
  23. pwd = getpwnam(userid);
  24. @@ -41,7 +42,7 @@ char *password;
  25. else if (pwd->pw_passwd[0] == '*') {
  26. r = "Account disabled";
  27. }
  28. - else if (strcmp(pwd->pw_passwd, crypt(password, pwd->pw_passwd)) != 0) {
  29. + else if (!(crpt_passwd = crypt(password, pwd->pw_passwd)) || strcmp(pwd->pw_passwd, (const char *)crpt_passwd) != 0) {
  30. r = "Incorrect password";
  31. }
  32. else {
  33. diff --git a/pwcheck/pwcheck_getspnam.c b/pwcheck/pwcheck_getspnam.c
  34. index 2b11286..6d607bb 100644
  35. --- a/pwcheck/pwcheck_getspnam.c
  36. +++ b/pwcheck/pwcheck_getspnam.c
  37. @@ -32,13 +32,15 @@ char *userid;
  38. char *password;
  39. {
  40. struct spwd *pwd;
  41. + char *crpt_passwd;
  42. pwd = getspnam(userid);
  43. if (!pwd) {
  44. return "Userid not found";
  45. }
  46. - if (strcmp(pwd->sp_pwdp, crypt(password, pwd->sp_pwdp)) != 0) {
  47. + crpt_passwd = crypt(password, pwd->sp_pwdp);
  48. + if (!crpt_passwd || strcmp(pwd->sp_pwdp, (const char *)crpt_passwd) != 0) {
  49. return "Incorrect password";
  50. }
  51. else {
  52. diff --git a/saslauthd/auth_getpwent.c b/saslauthd/auth_getpwent.c
  53. index fc8029d..d4ebe54 100644
  54. --- a/saslauthd/auth_getpwent.c
  55. +++ b/saslauthd/auth_getpwent.c
  56. @@ -77,6 +77,7 @@ auth_getpwent (
  57. {
  58. /* VARIABLES */
  59. struct passwd *pw; /* pointer to passwd file entry */
  60. + char *crpt_passwd; /* encrypted password */
  61. int errnum;
  62. /* END VARIABLES */
  63. @@ -105,7 +106,8 @@ auth_getpwent (
  64. }
  65. }
  66. - if (strcmp(pw->pw_passwd, (const char *)crypt(password, pw->pw_passwd))) {
  67. + crpt_passwd = crypt(password, pw->pw_passwd);
  68. + if (!crpt_passwd || strcmp(pw->pw_passwd, (const char *)crpt_passwd)) {
  69. if (flags & VERBOSE) {
  70. syslog(LOG_DEBUG, "DEBUG: auth_getpwent: %s: invalid password", login);
  71. }
  72. diff --git a/saslauthd/auth_shadow.c b/saslauthd/auth_shadow.c
  73. index 677131b..1988afd 100644
  74. --- a/saslauthd/auth_shadow.c
  75. +++ b/saslauthd/auth_shadow.c
  76. @@ -210,8 +210,8 @@ auth_shadow (
  77. RETURN("NO Insufficient permission to access NIS authentication database (saslauthd)");
  78. }
  79. - cpw = strdup((const char *)crypt(password, sp->sp_pwdp));
  80. - if (strcmp(sp->sp_pwdp, cpw)) {
  81. + cpw = crypt(password, sp->sp_pwdp);
  82. + if (!cpw || strcmp(sp->sp_pwdp, (const char *)cpw)) {
  83. if (flags & VERBOSE) {
  84. /*
  85. * This _should_ reveal the SHADOW_PW_LOCKED prefix to an
  86. @@ -221,10 +221,8 @@ auth_shadow (
  87. syslog(LOG_DEBUG, "DEBUG: auth_shadow: pw mismatch: '%s' != '%s'",
  88. sp->sp_pwdp, cpw);
  89. }
  90. - free(cpw);
  91. RETURN("NO Incorrect password");
  92. }
  93. - free(cpw);
  94. /*
  95. * The following fields will be set to -1 if:
  96. @@ -286,7 +284,7 @@ auth_shadow (
  97. RETURN("NO Invalid username");
  98. }
  99. - if (strcmp(upw->upw_passwd, crypt(password, upw->upw_passwd)) != 0) {
  100. + if (!(cpw = crypt(password, upw->upw_passwd)) || (strcmp(upw->upw_passwd, (const char *)cpw) != 0)) {
  101. if (flags & VERBOSE) {
  102. syslog(LOG_DEBUG, "auth_shadow: pw mismatch: %s != %s",
  103. password, upw->upw_passwd);
  104. --
  105. cgit v0.9.2