unzip-6.0-heap-overflow-infloop.patch 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. From bdd4a0cecd745cb4825e4508b5bdf2579731086a Mon Sep 17 00:00:00 2001
  2. From: Petr Stodulka <pstodulk@redhat.com>
  3. Date: Mon, 14 Sep 2015 18:23:17 +0200
  4. Subject: [PATCH 1/3] upstream fix for heap overflow
  5. https://bugzilla.redhat.com/attachment.cgi?id=1073002
  6. ---
  7. crypt.c | 12 +++++++++++-
  8. 1 file changed, 11 insertions(+), 1 deletion(-)
  9. diff --git a/crypt.c b/crypt.c
  10. index 784e411..a8975f2 100644
  11. --- a/crypt.c
  12. +++ b/crypt.c
  13. @@ -465,7 +465,17 @@ int decrypt(__G__ passwrd)
  14. GLOBAL(pInfo->encrypted) = FALSE;
  15. defer_leftover_input(__G);
  16. for (n = 0; n < RAND_HEAD_LEN; n++) {
  17. - b = NEXTBYTE;
  18. + /* 2012-11-23 SMS. (OUSPG report.)
  19. + * Quit early if compressed size < HEAD_LEN. The resulting
  20. + * error message ("unable to get password") could be improved,
  21. + * but it's better than trying to read nonexistent data, and
  22. + * then continuing with a negative G.csize. (See
  23. + * fileio.c:readbyte()).
  24. + */
  25. + if ((b = NEXTBYTE) == (ush)EOF)
  26. + {
  27. + return PK_ERR;
  28. + }
  29. h[n] = (uch)b;
  30. Trace((stdout, " (%02x)", h[n]));
  31. }
  32. --
  33. 2.4.6
  34. From 4b48844661ff9569f2ecf582a387d46a5775b5d8 Mon Sep 17 00:00:00 2001
  35. From: Kamil Dudka <kdudka@redhat.com>
  36. Date: Mon, 14 Sep 2015 18:24:56 +0200
  37. Subject: [PATCH 2/3] fix infinite loop when extracting empty bzip2 data
  38. Bug: https://sourceforge.net/p/infozip/patches/23/
  39. ---
  40. extract.c | 6 ++++++
  41. 1 file changed, 6 insertions(+)
  42. diff --git a/extract.c b/extract.c
  43. index 7134bfe..29db027 100644
  44. --- a/extract.c
  45. +++ b/extract.c
  46. @@ -2733,6 +2733,12 @@ __GDEF
  47. int repeated_buf_err;
  48. bz_stream bstrm;
  49. + if (G.incnt <= 0 && G.csize <= 0L) {
  50. + /* avoid an infinite loop */
  51. + Trace((stderr, "UZbunzip2() got empty input\n"));
  52. + return 2;
  53. + }
  54. +
  55. #if (defined(DLL) && !defined(NO_SLIDE_REDIR))
  56. if (G.redirect_slide)
  57. wsize = G.redirect_size, redirSlide = G.redirect_buffer;
  58. --
  59. 2.4.6
  60. From bd150334fb4084f5555a6be26b015a0671cb5b74 Mon Sep 17 00:00:00 2001
  61. From: Kamil Dudka <kdudka@redhat.com>
  62. Date: Tue, 22 Sep 2015 18:52:23 +0200
  63. Subject: [PATCH 3/3] extract: prevent unsigned overflow on invalid input
  64. Suggested-by: Stefan Cornelius
  65. ---
  66. extract.c | 11 ++++++++++-
  67. 1 file changed, 10 insertions(+), 1 deletion(-)
  68. diff --git a/extract.c b/extract.c
  69. index 29db027..b9ae667 100644
  70. --- a/extract.c
  71. +++ b/extract.c
  72. @@ -1257,8 +1257,17 @@ static int extract_or_test_entrylist(__G__ numchunk,
  73. if (G.lrec.compression_method == STORED) {
  74. zusz_t csiz_decrypted = G.lrec.csize;
  75. - if (G.pInfo->encrypted)
  76. + if (G.pInfo->encrypted) {
  77. + if (csiz_decrypted < 12) {
  78. + /* handle the error now to prevent unsigned overflow */
  79. + Info(slide, 0x401, ((char *)slide,
  80. + LoadFarStringSmall(ErrUnzipNoFile),
  81. + LoadFarString(InvalidComprData),
  82. + LoadFarStringSmall2(Inflate)));
  83. + return PK_ERR;
  84. + }
  85. csiz_decrypted -= 12;
  86. + }
  87. if (G.lrec.ucsize != csiz_decrypted) {
  88. Info(slide, 0x401, ((char *)slide,
  89. LoadFarStringSmall2(WrnStorUCSizCSizDiff),
  90. --
  91. 2.5.2