0001-In-stamp-always-advance-the-pointer-if-p-0xef.patch 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. From f7ca0035d17a663f55668e662b840afce7b86112 Mon Sep 17 00:00:00 2001
  2. From: Christian Voegl <cvoegl@suse.com>
  3. Date: Wed, 27 Oct 2021 11:25:18 +0200
  4. Subject: [PATCH] In stamp always advance the pointer if *p= 0xef
  5. The current implementation only advanced if 0xef is followed
  6. by two non-zero bytes. In case of malformed input (0xef should be
  7. the start byte of a three byte character) this leads to an infinite
  8. loop. (CVE-2021-42260)
  9. [Retrieved (and backported) from:
  10. https://sourceforge.net/p/tinyxml/git/merge-requests/1]
  11. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  12. ---
  13. tinyxmlparser.cpp | 6 ++++++
  14. 1 file changed, 6 insertions(+)
  15. diff --git a/src/tinyxmlparser.cpp b/src/tinyxmlparser.cpp
  16. index 81b7eae..8aa0dfa 100755
  17. --- a/src/tinyxmlparser.cpp
  18. +++ b/src/tinyxmlparser.cpp
  19. @@ -274,6 +274,12 @@ void TiXmlParsingData::Stamp( const char* now, TiXmlEncoding encoding )
  20. else
  21. { p +=3; ++col; } // A normal character.
  22. }
  23. + else
  24. + {
  25. + // TIXML_UTF_LEAD_0 (239) is the start character of a 3 byte sequence, so
  26. + // there is something wrong here. Just advance the pointer to evade infinite loops
  27. + ++p;
  28. + }
  29. }
  30. else
  31. {
  32. --
  33. 2.34.1