You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
996 B

  1. From 0e1a49c8907645d2e155f0d89d4d9895ac5112b5 Mon Sep 17 00:00:00 2001
  2. From: Zhipeng Xie <xiezhipeng1@huawei.com>
  3. Date: Thu, 12 Dec 2019 17:30:55 +0800
  4. Subject: [PATCH] Fix infinite loop in xmlStringLenDecodeEntities
  5. When ctxt->instate == XML_PARSER_EOF,xmlParseStringEntityRef
  6. return NULL which cause a infinite loop in xmlStringLenDecodeEntities
  7. Found with libFuzzer.
  8. Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
  9. ---
  10. parser.c | 3 ++-
  11. 1 file changed, 2 insertions(+), 1 deletion(-)
  12. diff --git a/parser.c b/parser.c
  13. index d1c319631..a34bb6cdd 100644
  14. --- a/parser.c
  15. +++ b/parser.c
  16. @@ -2646,7 +2646,8 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
  17. else
  18. c = 0;
  19. while ((c != 0) && (c != end) && /* non input consuming loop */
  20. - (c != end2) && (c != end3)) {
  21. + (c != end2) && (c != end3) &&
  22. + (ctxt->instate != XML_PARSER_EOF)) {
  23. if (c == 0) break;
  24. if ((c == '&') && (str[1] == '#')) {
  25. --
  26. GitLab