1*2a621114SDon LewisFrom 0e1a49c8907645d2e155f0d89d4d9895ac5112b5 Mon Sep 17 00:00:00 2001 2*2a621114SDon LewisFrom: Zhipeng Xie <xiezhipeng1@huawei.com> 3*2a621114SDon LewisDate: Thu, 12 Dec 2019 17:30:55 +0800 4*2a621114SDon LewisSubject: [PATCH] Fix infinite loop in xmlStringLenDecodeEntities 5*2a621114SDon Lewis 6*2a621114SDon LewisWhen ctxt->instate == XML_PARSER_EOF,xmlParseStringEntityRef 7*2a621114SDon Lewisreturn NULL which cause a infinite loop in xmlStringLenDecodeEntities 8*2a621114SDon Lewis 9*2a621114SDon LewisFound with libFuzzer. 10*2a621114SDon Lewis 11*2a621114SDon LewisSigned-off-by: Zhipeng Xie <xiezhipeng1@huawei.com> 12*2a621114SDon Lewis--- 13*2a621114SDon Lewis parser.c | 3 ++- 14*2a621114SDon Lewis 1 file changed, 2 insertions(+), 1 deletion(-) 15*2a621114SDon Lewis 16*2a621114SDon Lewisdiff --git misc/libxml2-2.9.10/parser.c misc/build/libxml2-2.9.10/parser.c 17*2a621114SDon Lewisindex d1c319631..a34bb6cdd 100644 18*2a621114SDon Lewis--- misc/libxml2-2.9.10/parser.c 19*2a621114SDon Lewis+++ misc/build/libxml2-2.9.10/parser.c 20*2a621114SDon Lewis@@ -2646,7 +2646,8 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len, 21*2a621114SDon Lewis else 22*2a621114SDon Lewis c = 0; 23*2a621114SDon Lewis while ((c != 0) && (c != end) && /* non input consuming loop */ 24*2a621114SDon Lewis- (c != end2) && (c != end3)) { 25*2a621114SDon Lewis+ (c != end2) && (c != end3) && 26*2a621114SDon Lewis+ (ctxt->instate != XML_PARSER_EOF)) { 27*2a621114SDon Lewis 28*2a621114SDon Lewis if (c == 0) break; 29*2a621114SDon Lewis if ((c == '&') && (str[1] == '#')) { 30*2a621114SDon Lewis-- 31*2a621114SDon LewisGitLab 32*2a621114SDon Lewis 33