Fixed to not call xmlReadMemory if data length is 0
This commit is contained in:
committed by
Andrew Gaul
parent
2cb869dfd2
commit
a9b9631c5c
10
src/s3fs.cpp
10
src/s3fs.cpp
@ -3586,6 +3586,16 @@ static int list_bucket(const char* path, S3ObjList& head, const char* delimiter,
|
|||||||
//
|
//
|
||||||
std::string encbody = get_encoded_cr_code(responseBody.c_str());
|
std::string encbody = get_encoded_cr_code(responseBody.c_str());
|
||||||
|
|
||||||
|
// [NOTE]
|
||||||
|
// If encbody is empty, xmlReadMemory will output the message
|
||||||
|
// ":1: parser error : Document is empty" to stderr.
|
||||||
|
// Make sure encbody is not empty beforehand.
|
||||||
|
//
|
||||||
|
if(encbody.empty()){
|
||||||
|
S3FS_PRN_ERR("The data length passed to xmlReadMemory is 0.");
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
// xmlDocPtr
|
// xmlDocPtr
|
||||||
std::unique_ptr<xmlDoc, decltype(&xmlFreeDoc)> doc(xmlReadMemory(encbody.c_str(), static_cast<int>(encbody.size()), "", nullptr, 0), xmlFreeDoc);
|
std::unique_ptr<xmlDoc, decltype(&xmlFreeDoc)> doc(xmlReadMemory(encbody.c_str(), static_cast<int>(encbody.size()), "", nullptr, 0), xmlFreeDoc);
|
||||||
if(nullptr == doc){
|
if(nullptr == doc){
|
||||||
|
|||||||
@ -451,11 +451,16 @@ bool simple_parse_xml(const char* data, size_t len, const char* key, std::string
|
|||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
if(!data || !key){
|
if(!data || !key || 0 == len){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
value.clear();
|
value.clear();
|
||||||
|
|
||||||
|
// [NOTE]
|
||||||
|
// If data is not nullptr and len is 0, this function will output the message
|
||||||
|
// ":1: parser error : Document is empty" to stderr.
|
||||||
|
// Make sure len is not 0 beforehand.
|
||||||
|
//
|
||||||
std::unique_ptr<xmlDoc, decltype(&xmlFreeDoc)> doc(xmlReadMemory(data, static_cast<int>(len), "", nullptr, 0), xmlFreeDoc);
|
std::unique_ptr<xmlDoc, decltype(&xmlFreeDoc)> doc(xmlReadMemory(data, static_cast<int>(len), "", nullptr, 0), xmlFreeDoc);
|
||||||
if(nullptr == doc){
|
if(nullptr == doc){
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user