enscript-1.6.4-CVE-2008-3863-CVE-2008-4306.patch 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. --- src/psgen.c
  2. +++ src/psgen.c 2008-10-29 10:43:08.512598143 +0100
  3. @@ -24,6 +24,7 @@
  4. * Boston, MA 02111-1307, USA.
  5. */
  6. +#include <limits.h>
  7. #include "gsint.h"
  8. /*
  9. @@ -124,7 +125,7 @@ struct gs_token_st
  10. double xscale;
  11. double yscale;
  12. int llx, lly, urx, ury; /* Bounding box. */
  13. - char filename[512];
  14. + char filename[PATH_MAX];
  15. char *skipbuf;
  16. unsigned int skipbuf_len;
  17. unsigned int skipbuf_pos;
  18. @@ -135,11 +136,11 @@ struct gs_token_st
  19. Color bgcolor;
  20. struct
  21. {
  22. - char name[512];
  23. + char name[PATH_MAX];
  24. FontPoint size;
  25. InputEncoding encoding;
  26. } font;
  27. - char filename[512];
  28. + char filename[PATH_MAX];
  29. } u;
  30. };
  31. @@ -248,7 +249,7 @@ static int do_print = 1;
  32. static int user_fontp = 0;
  33. /* The user ^@font{}-defined font. */
  34. -static char user_font_name[256];
  35. +static char user_font_name[PATH_MAX];
  36. static FontPoint user_font_pt;
  37. static InputEncoding user_font_encoding;
  38. @@ -978,7 +979,8 @@ large for page\n"),
  39. FATAL ((stderr,
  40. _("user font encoding can be only the system's default or `ps'")));
  41. - strcpy (user_font_name, token.u.font.name);
  42. + memset (user_font_name, 0, sizeof(user_font_name));
  43. + strncpy (user_font_name, token.u.font.name, sizeof(user_font_name) - 1);
  44. user_font_pt.w = token.u.font.size.w;
  45. user_font_pt.h = token.u.font.size.h;
  46. user_font_encoding = token.u.font.encoding;
  47. @@ -1444,7 +1446,7 @@ read_special_escape (InputStream *is, To
  48. buf[i] = ch;
  49. if (i + 1 >= sizeof (buf))
  50. FATAL ((stderr, _("too long argument for %s escape:\n%.*s"),
  51. - escapes[i].name, i, buf));
  52. + escapes[e].name, i, buf));
  53. }
  54. buf[i] = '\0';
  55. @@ -1452,7 +1454,8 @@ read_special_escape (InputStream *is, To
  56. switch (escapes[e].escape)
  57. {
  58. case ESC_FONT:
  59. - strcpy (token->u.font.name, buf);
  60. + memset (token->u.font.name, 0, sizeof(token->u.font.name));
  61. + strncpy (token->u.font.name, buf, sizeof(token->u.font.name) - 1);
  62. /* Check for the default font. */
  63. if (strcmp (token->u.font.name, "default") == 0)
  64. @@ -1465,7 +1468,8 @@ read_special_escape (InputStream *is, To
  65. FATAL ((stderr, _("malformed font spec for ^@font escape: %s"),
  66. token->u.font.name));
  67. - strcpy (token->u.font.name, cp);
  68. + memset (token->u.font.name, 0, sizeof(token->u.font.name));
  69. + strncpy (token->u.font.name, cp, sizeof(token->u.font.name) - 1);
  70. xfree (cp);
  71. }
  72. token->type = tFONT;
  73. @@ -1544,7 +1548,8 @@ read_special_escape (InputStream *is, To
  74. break;
  75. case ESC_SETFILENAME:
  76. - strcpy (token->u.filename, buf);
  77. + memset (token->u.filename, 0, sizeof(token->u.font.name));
  78. + strncpy (token->u.filename, buf, sizeof(token->u.filename) - 1);
  79. token->type = tSETFILENAME;
  80. break;