You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.4 KiB

  1. From 0c74a9f49b8d7a36b17b54a7428b3526d20f88a8 Mon Sep 17 00:00:00 2001
  2. From: Scott Gayou <github.scott@gmail.com>
  3. Date: Wed, 23 Jan 2019 15:03:53 -0500
  4. Subject: [PATCH] Fix for simple memory leak that was assigned CVE-2019-6128.
  5. pal2rgb failed to free memory on a few errors. This was reported
  6. here: http://bugzilla.maptools.org/show_bug.cgi?id=2836.
  7. ---
  8. tools/pal2rgb.c | 7 ++++++-
  9. 1 file changed, 6 insertions(+), 1 deletion(-)
  10. diff --git a/tools/pal2rgb.c b/tools/pal2rgb.c
  11. index 01d8502e..9492f1cf 100644
  12. --- a/tools/pal2rgb.c
  13. +++ b/tools/pal2rgb.c
  14. @@ -118,12 +118,14 @@ main(int argc, char* argv[])
  15. shortv != PHOTOMETRIC_PALETTE) {
  16. fprintf(stderr, "%s: Expecting a palette image.\n",
  17. argv[optind]);
  18. + (void) TIFFClose(in);
  19. return (-1);
  20. }
  21. if (!TIFFGetField(in, TIFFTAG_COLORMAP, &rmap, &gmap, &bmap)) {
  22. fprintf(stderr,
  23. "%s: No colormap (not a valid palette image).\n",
  24. argv[optind]);
  25. + (void) TIFFClose(in);
  26. return (-1);
  27. }
  28. bitspersample = 0;
  29. @@ -131,11 +133,14 @@ main(int argc, char* argv[])
  30. if (bitspersample != 8) {
  31. fprintf(stderr, "%s: Sorry, can only handle 8-bit images.\n",
  32. argv[optind]);
  33. + (void) TIFFClose(in);
  34. return (-1);
  35. }
  36. out = TIFFOpen(argv[optind+1], "w");
  37. - if (out == NULL)
  38. + if (out == NULL) {
  39. + (void) TIFFClose(in);
  40. return (-2);
  41. + }
  42. cpTags(in, out);
  43. TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &imagewidth);
  44. TIFFGetField(in, TIFFTAG_IMAGELENGTH, &imagelength);
  45. --
  46. 2.18.1