csiz-underflow.patch 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. From: Kamil Dudka <kdudka@redhat.com>
  2. Date: Tue, 22 Sep 2015 18:52:23 +0200
  3. Subject: [PATCH] extract: prevent unsigned overflow on invalid input
  4. Origin: other, https://bugzilla.redhat.com/attachment.cgi?id=1075942
  5. Bug-RedHat: https://bugzilla.redhat.com/show_bug.cgi?id=1260944
  6. Suggested-by: Stefan Cornelius
  7. ---
  8. extract.c | 11 ++++++++++-
  9. 1 file changed, 10 insertions(+), 1 deletion(-)
  10. --- a/extract.c
  11. +++ b/extract.c
  12. @@ -1257,8 +1257,17 @@
  13. if (G.lrec.compression_method == STORED) {
  14. zusz_t csiz_decrypted = G.lrec.csize;
  15. - if (G.pInfo->encrypted)
  16. + if (G.pInfo->encrypted) {
  17. + if (csiz_decrypted < 12) {
  18. + /* handle the error now to prevent unsigned overflow */
  19. + Info(slide, 0x401, ((char *)slide,
  20. + LoadFarStringSmall(ErrUnzipNoFile),
  21. + LoadFarString(InvalidComprData),
  22. + LoadFarStringSmall2(Inflate)));
  23. + return PK_ERR;
  24. + }
  25. csiz_decrypted -= 12;
  26. + }
  27. if (G.lrec.ucsize != csiz_decrypted) {
  28. Info(slide, 0x401, ((char *)slide,
  29. LoadFarStringSmall2(WrnStorUCSizCSizDiff),