cracklib-2.9.6-CVE-2016-6318.patch 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. From 47e5dec521ab6243c9b249dd65b93d232d90d6b1 Mon Sep 17 00:00:00 2001
  2. From: Jan Dittberner <jan@dittberner.info>
  3. Date: Thu, 25 Aug 2016 17:13:49 +0200
  4. Subject: [PATCH] Apply patch to fix CVE-2016-6318
  5. This patch fixes an issue with a stack-based buffer overflow whne
  6. parsing large GECOS field. See
  7. https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-6318 and
  8. https://security-tracker.debian.org/tracker/CVE-2016-6318 for more
  9. information.
  10. ---
  11. src/NEWS | 1 +
  12. src/lib/fascist.c | 57 ++++++++++++++++++++++++++++++++-----------------------
  13. 2 files changed, 34 insertions(+), 24 deletions(-)
  14. diff --git a/src/NEWS b/src/NEWS
  15. index 26abeee..361a207 100644
  16. --- a/src/NEWS
  17. +++ b/src/NEWS
  18. @@ -1,3 +1,4 @@
  19. +v2.9.x apply patch to fix CVE-2016-6318 Stack-based buffer overflow when parsing large GECOS field
  20. v2.9.6 updates to cracklib-words to add a bunch of other dictionary lists
  21. migration to github
  22. patch to add some particularly bad cases to the cracklib small dictionary (Matthew Miller)
  23. diff --git a/src/lib/fascist.c b/src/lib/fascist.c
  24. index a996509..d4deb15 100644
  25. --- a/src/lib/fascist.c
  26. +++ b/src/lib/fascist.c
  27. @@ -502,7 +502,7 @@ FascistGecosUser(char *password, const char *user, const char *gecos)
  28. char gbuffer[STRINGSIZE];
  29. char tbuffer[STRINGSIZE];
  30. char *uwords[STRINGSIZE];
  31. - char longbuffer[STRINGSIZE * 2];
  32. + char longbuffer[STRINGSIZE];
  33. if (gecos == NULL)
  34. gecos = "";
  35. @@ -583,38 +583,47 @@ FascistGecosUser(char *password, const char *user, const char *gecos)
  36. {
  37. for (i = 0; i < j; i++)
  38. {
  39. - strcpy(longbuffer, uwords[i]);
  40. - strcat(longbuffer, uwords[j]);
  41. -
  42. - if (GTry(longbuffer, password))
  43. + if (strlen(uwords[i]) + strlen(uwords[j]) < STRINGSIZE)
  44. {
  45. - return _("it is derived from your password entry");
  46. - }
  47. + strcpy(longbuffer, uwords[i]);
  48. + strcat(longbuffer, uwords[j]);
  49. - strcpy(longbuffer, uwords[j]);
  50. - strcat(longbuffer, uwords[i]);
  51. + if (GTry(longbuffer, password))
  52. + {
  53. + return _("it is derived from your password entry");
  54. + }
  55. - if (GTry(longbuffer, password))
  56. - {
  57. - return _("it's derived from your password entry");
  58. - }
  59. + strcpy(longbuffer, uwords[j]);
  60. + strcat(longbuffer, uwords[i]);
  61. - longbuffer[0] = uwords[i][0];
  62. - longbuffer[1] = '\0';
  63. - strcat(longbuffer, uwords[j]);
  64. + if (GTry(longbuffer, password))
  65. + {
  66. + return _("it's derived from your password entry");
  67. + }
  68. + }
  69. - if (GTry(longbuffer, password))
  70. + if (strlen(uwords[j]) < STRINGSIZE - 1)
  71. {
  72. - return _("it is derivable from your password entry");
  73. + longbuffer[0] = uwords[i][0];
  74. + longbuffer[1] = '\0';
  75. + strcat(longbuffer, uwords[j]);
  76. +
  77. + if (GTry(longbuffer, password))
  78. + {
  79. + return _("it is derivable from your password entry");
  80. + }
  81. }
  82. - longbuffer[0] = uwords[j][0];
  83. - longbuffer[1] = '\0';
  84. - strcat(longbuffer, uwords[i]);
  85. -
  86. - if (GTry(longbuffer, password))
  87. + if (strlen(uwords[i]) < STRINGSIZE - 1)
  88. {
  89. - return _("it's derivable from your password entry");
  90. + longbuffer[0] = uwords[j][0];
  91. + longbuffer[1] = '\0';
  92. + strcat(longbuffer, uwords[i]);
  93. +
  94. + if (GTry(longbuffer, password))
  95. + {
  96. + return _("it's derivable from your password entry");
  97. + }
  98. }
  99. }
  100. }