From 868a2b79547a879d00ae9a0c2a6c46a2b6184226 Mon Sep 17 00:00:00 2001 From: Bin Hu Date: Sat, 26 Mar 2022 14:27:22 +0800 Subject: [PATCH 5/6] fix return value of parsing wrong formed metalink file Signed-off-by: Bin Hu --- lib/libexpat_metalink_parser.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletions(-) diff --git a/lib/libexpat_metalink_parser.c b/lib/libexpat_metalink_parser.c index 79b091c..11a8eee 100644 --- a/lib/libexpat_metalink_parser.c +++ b/lib/libexpat_metalink_parser.c @@ -149,6 +149,7 @@ metalink_parse_fp(FILE* docfp, metalink_t** res) metalink_error_t r = 0, retval; XML_Parser parser; + int isFinal = 0; session_data = metalink_session_data_new(); @@ -172,7 +173,10 @@ metalink_parse_fp(FILE* docfp, metalink_t** res) assert(0); } } - if(!XML_ParseBuffer(parser, num_read, 0)) { + if(feof(docfp)) { + isFinal = 1; + } + if(!XML_ParseBuffer(parser, num_read, isFinal)) { r = METALINK_ERR_PARSER_ERROR; break; } -- 2.28.0.windows.1