patch-list_c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. $OpenBSD: patch-list_c,v 1.1 2017/03/23 17:26:17 bluhm Exp $
  2. Fix: increase size of cfactorstr array to avoid buffer overflow
  3. https://bugs.debian.org/741384
  4. Fix CVE-2014-9913: buffer overflow in unzip
  5. https://sourceforge.net/p/infozip/bugs/27/
  6. https://bugs.debian.org/847485
  7. https://launchpad.net/bugs/387350
  8. --- list.c.orig Sun Feb 8 18:11:34 2009
  9. +++ list.c Tue Mar 21 16:10:27 2017
  10. @@ -97,7 +97,7 @@ int list_files(__G) /* return PK-type error code */
  11. {
  12. int do_this_file=FALSE, cfactor, error, error_in_archive=PK_COOL;
  13. #ifndef WINDLL
  14. - char sgn, cfactorstr[10];
  15. + char sgn, cfactorstr[12];
  16. int longhdr=(uO.vflag>1);
  17. #endif
  18. int date_format;
  19. @@ -339,7 +339,18 @@ int list_files(__G) /* return PK-type error code */
  20. G.crec.compression_method == ENHDEFLATED) {
  21. methbuf[5] = dtype[(G.crec.general_purpose_bit_flag>>1) & 3];
  22. } else if (methnum >= NUM_METHODS) {
  23. - sprintf(&methbuf[4], "%03u", G.crec.compression_method);
  24. + /* 2013-02-26 SMS.
  25. + * http://sourceforge.net/p/infozip/bugs/27/ CVE-2014-9913.
  26. + * Unexpectedly large compression methods overflow
  27. + * &methbuf[]. Use the old, three-digit decimal format
  28. + * for values which fit. Otherwise, sacrifice the
  29. + * colon, and use four-digit hexadecimal.
  30. + */
  31. + if (G.crec.compression_method <= 999) {
  32. + sprintf( &methbuf[ 4], "%03u", G.crec.compression_method);
  33. + } else {
  34. + sprintf( &methbuf[ 3], "%04X", G.crec.compression_method);
  35. + }
  36. }
  37. #if 0 /* GRR/Euro: add this? */