gegl-0.2.0-cve-2012-4433-4757cdf7.patch 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. From 4757cdf73d3675478d645a3ec8250ba02168a230 Mon Sep 17 00:00:00 2001
  2. From: Nils Philippsen <nils@redhat.com>
  3. Date: Tue, 16 Oct 2012 14:56:40 +0000
  4. Subject: ppm-load: CVE-2012-4433: add plausibility checks for header fields
  5. Refuse values that are non-decimal, negative or overflow the target
  6. type.
  7. ---
  8. diff --git a/operations/external/ppm-load.c b/operations/external/ppm-load.c
  9. index 3d6bce7..465096d 100644
  10. --- a/operations/external/ppm-load.c
  11. +++ b/operations/external/ppm-load.c
  12. @@ -36,6 +36,7 @@ gegl_chant_file_path (path, _("File"), "", _("Path of file to load."))
  13. #include "gegl-chant.h"
  14. #include <stdio.h>
  15. #include <stdlib.h>
  16. +#include <errno.h>
  17. typedef enum {
  18. PIXMAP_ASCII = 51,
  19. @@ -44,8 +45,8 @@ typedef enum {
  20. typedef struct {
  21. map_type type;
  22. - gint width;
  23. - gint height;
  24. + glong width;
  25. + glong height;
  26. gsize numsamples; /* width * height * channels */
  27. gsize bpc; /* bytes per channel */
  28. guchar *data;
  29. @@ -82,11 +83,33 @@ ppm_load_read_header(FILE *fp,
  30. }
  31. /* Get Width and Height */
  32. - img->width = strtol (header,&ptr,0);
  33. - img->height = atoi (ptr);
  34. + errno = 0;
  35. + img->width = strtol (header,&ptr,10);
  36. + if (errno)
  37. + {
  38. + g_warning ("Error reading width: %s", strerror(errno));
  39. + return FALSE;
  40. + }
  41. + else if (img->width < 0)
  42. + {
  43. + g_warning ("Error: width is negative");
  44. + return FALSE;
  45. + }
  46. +
  47. + img->height = strtol (ptr,&ptr,10);
  48. + if (errno)
  49. + {
  50. + g_warning ("Error reading height: %s", strerror(errno));
  51. + return FALSE;
  52. + }
  53. + else if (img->width < 0)
  54. + {
  55. + g_warning ("Error: height is negative");
  56. + return FALSE;
  57. + }
  58. fgets (header,MAX_CHARS_IN_ROW,fp);
  59. - maxval = strtol (header,&ptr,0);
  60. + maxval = strtol (header,&ptr,10);
  61. if ((maxval != 255) && (maxval != 65535))
  62. {
  63. --
  64. cgit v0.9.0.2