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.

27 lines
879 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. --- a/parser.c
  13. +++ b/parser.c
  14. @@ -2646,7 +2646,8 @@ xmlStringLenDecodeEntities(xmlParserCtxt
  15. else
  16. c = 0;
  17. while ((c != 0) && (c != end) && /* non input consuming loop */
  18. - (c != end2) && (c != end3)) {
  19. + (c != end2) && (c != end3) &&
  20. + (ctxt->instate != XML_PARSER_EOF)) {
  21. if (c == 0) break;
  22. if ((c == '&') && (str[1] == '#')) {