0003-CVE-2012-4527.patch 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. Fix for CVE-2012-4527.
  2. Authored by Attila Bogar and Jean-Michel Vourgère <jmv_deb@nirgal.com>
  3. Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
  4. diff -Nura mcrypt-2.6.8.orig/src/mcrypt.c mcrypt-2.6.8/src/mcrypt.c
  5. --- mcrypt-2.6.8.orig/src/mcrypt.c 2013-01-14 19:15:49.465925072 -0300
  6. +++ mcrypt-2.6.8/src/mcrypt.c 2013-01-14 19:28:13.711478000 -0300
  7. @@ -44,7 +44,9 @@
  8. static char rcsid[] =
  9. "$Id: mcrypt.c,v 1.2 2007/11/07 17:10:21 nmav Exp $";
  10. -char tmperr[128];
  11. +/* Temporary error message can contain one file name and 1k of text */
  12. +#define ERRWIDTH ((PATH_MAX)+1024)
  13. +char tmperr[ERRWIDTH];
  14. unsigned int stream_flag = FALSE;
  15. char *keymode = NULL;
  16. char *mode = NULL;
  17. @@ -482,7 +484,7 @@
  18. #ifdef HAVE_STAT
  19. if (stream_flag == FALSE) {
  20. if (is_normal_file(file[i]) == FALSE) {
  21. - sprintf(tmperr,
  22. + snprintf(tmperr, ERRWIDTH,
  23. _
  24. ("%s: %s is not a regular file. Skipping...\n"),
  25. program_name, file[i]);
  26. @@ -501,7 +503,7 @@
  27. dinfile = file[i];
  28. if ((isatty(fileno((FILE *) (stdin))) == 1)
  29. && (stream_flag == TRUE) && (force == 0)) { /* not a tty */
  30. - sprintf(tmperr,
  31. + snprintf(tmperr, ERRWIDTH,
  32. _
  33. ("%s: Encrypted data will not be read from a terminal.\n"),
  34. program_name);
  35. @@ -520,7 +522,7 @@
  36. einfile = file[i];
  37. if ((isatty(fileno((FILE *) (stdout))) == 1)
  38. && (stream_flag == TRUE) && (force == 0)) { /* not a tty */
  39. - sprintf(tmperr,
  40. + snprintf(tmperr, ERRWIDTH,
  41. _
  42. ("%s: Encrypted data will not be written to a terminal.\n"),
  43. program_name);
  44. @@ -544,7 +546,7 @@
  45. strcpy(outfile, einfile);
  46. /* if file has already the .nc ignore it */
  47. if (strstr(outfile, ".nc") != NULL) {
  48. - sprintf(tmperr,
  49. + snprintf(tmperr, ERRWIDTH,
  50. _
  51. ("%s: file %s has the .nc suffix... skipping...\n"),
  52. program_name, outfile);
  53. @@ -590,10 +592,10 @@
  54. if (x == 0) {
  55. if (stream_flag == FALSE) {
  56. - sprintf(tmperr, _("File %s was decrypted.\n"), dinfile);
  57. + snprintf(tmperr, ERRWIDTH, _("File %s was decrypted.\n"), dinfile);
  58. err_warn(tmperr);
  59. } else {
  60. - sprintf(tmperr, _("Stdin was decrypted.\n"));
  61. + snprintf(tmperr, ERRWIDTH, _("Stdin was decrypted.\n"));
  62. err_warn(tmperr);
  63. }
  64. #ifdef HAVE_STAT
  65. @@ -610,7 +612,7 @@
  66. } else {
  67. if (stream_flag == FALSE) {
  68. - sprintf(tmperr,
  69. + snprintf(tmperr, ERRWIDTH,
  70. _
  71. ("File %s was NOT decrypted successfully.\n"),
  72. dinfile);
  73. @@ -636,10 +638,10 @@
  74. if (x == 0) {
  75. if (stream_flag == FALSE) {
  76. - sprintf(tmperr, _("File %s was encrypted.\n"), einfile);
  77. + snprintf(tmperr, ERRWIDTH, _("File %s was encrypted.\n"), einfile);
  78. err_warn(tmperr);
  79. } else {
  80. - sprintf(tmperr, _("Stdin was encrypted.\n"));
  81. + snprintf(tmperr, ERRWIDTH, _("Stdin was encrypted.\n"));
  82. err_warn(tmperr);
  83. }
  84. #ifdef HAVE_STAT
  85. @@ -655,7 +657,7 @@
  86. } else {
  87. if (stream_flag == FALSE) {
  88. - sprintf(tmperr,
  89. + snprintf(tmperr, ERRWIDTH,
  90. _
  91. ("File %s was NOT encrypted successfully.\n"),
  92. einfile);