libmetalink/0005-fix-return-value-of-parsing-wrong-formed-metalink-fi.patch
hubin 635979e215 fix return value bug when parsing wrong formed metalink file
Signed-off-by: hubin <hubin73@huawei.com>
2022-03-28 09:30:28 +08:00

38 lines
1.1 KiB
Diff

From 868a2b79547a879d00ae9a0c2a6c46a2b6184226 Mon Sep 17 00:00:00 2001
From: Bin Hu <hubin73@huawei.com>
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 <hubin73@huawei.com>
---
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