0019-Fix-OOB-heap-read-in-xsltExtModuleRegisterDynamic.patch 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. From 87c3d9ea214fc0503fd8130b6dd97431d69cc066 Mon Sep 17 00:00:00 2001
  2. From: Nick Wellnhofer <wellnhofer@aevum.de>
  3. Date: Thu, 5 May 2016 15:12:48 +0200
  4. Subject: [PATCH] Fix OOB heap read in xsltExtModuleRegisterDynamic
  5. xsltExtModuleRegisterDynamic would read a byte before the start of a
  6. string under certain circumstances. I looks like this piece code was
  7. supposed to strip characters from the end of the extension name, but
  8. it didn't have any effect. Don't read beyond the beginning of the
  9. string and actually strip unwanted characters.
  10. Found with afl-fuzz and ASan.
  11. ---
  12. libxslt/extensions.c | 5 ++++-
  13. 1 file changed, 4 insertions(+), 1 deletion(-)
  14. diff --git a/libxslt/extensions.c b/libxslt/extensions.c
  15. index 5ad73cb..ae6eef0 100644
  16. --- a/libxslt/extensions.c
  17. +++ b/libxslt/extensions.c
  18. @@ -367,8 +367,11 @@ xsltExtModuleRegisterDynamic(const xmlChar * URI)
  19. i++;
  20. }
  21. - if (*(i - 1) == '_')
  22. + /* Strip underscores from end of string. */
  23. + while (i > ext_name && *(i - 1) == '_') {
  24. + i--;
  25. *i = '\0';
  26. + }
  27. /* determine module directory */
  28. ext_directory = (xmlChar *) getenv("LIBXSLT_PLUGINS_PATH");
  29. --
  30. 2.8.1