plist : incorrect use of LString8. Memory was NOT copied in TagString,

TagKey, TagDate.
This commit is contained in:
jief666 2024-01-07 15:54:17 +01:00
parent 4b2722a30e
commit 5faf2f688b
5 changed files with 23 additions and 8 deletions

View File

@ -46,10 +46,12 @@ public:
}
void setDateValue(const XString8& xstring)
{
// if ( xstring.isEmpty() ) panic("TagDate::setDateValue() : xstring.isEmpty() ");
if ( xstring.isEmpty() ) return; //do nothing rather then assign empty date
string = xstring;
}
void setDateValue(const char* value, size_t length)
{
string.strncpy(value, length); // strncpy can handle value==NULL, *value=0 and length=0
}
};

View File

@ -51,9 +51,15 @@ public:
}
void setKeyValue(const XString8& xstring)
{
if ( xstring.isEmpty() ) log_technical_bug("TagKey::setKeyValue() : xstring.isEmpty() ");
// if ( xstring.isEmpty() ) log_technical_bug("TagKey::setKeyValue() : xstring.isEmpty() ");
_string = xstring;
}
void setKeyValue(const char* value, size_t length)
{
// if ( value == NULL ) log_technical_bug("TagKey::setKeyValue() : value==NULL ");
// if ( *value == 0 ) log_technical_bug("TagKey::setKeyValue() : *value==0 ");
_string.strncpy(value, length);
}
};

View File

@ -52,9 +52,12 @@ public:
void setStringValue(const XString8& xstring)
{
// empty string is allowed
//if ( xstring.isEmpty() ) panic("TagStruct::setStringValue() : xstring.isEmpty() ");
_string = xstring;
}
void setStringValue(const char* value, size_t length)
{
_string.strncpy(value, length); // strncpy can handle value==NULL, *value=0 and length=0
}
};

View File

@ -446,7 +446,7 @@ EFI_STATUS ParseTagKey( char * buffer, TagStruct** tag, UINT32* lenPtr)
// return Status;
// }
tmpTag = TagKey::getEmptyTag();
tmpTag->setKeyValue(LString8(buffer, strlen(buffer)));
tmpTag->setKeyValue(buffer, strlen(buffer));
*tag = tmpTag;
*lenPtr = length + length2;
@ -474,7 +474,7 @@ EFI_STATUS ParseTagString(CHAR8* buffer, TagStruct* * tag,UINT32* lenPtr)
}
size_t outlen = XMLDecode(buffer, strlen(buffer), buffer, strlen(buffer));
tmpTag->setStringValue(LString8(buffer, outlen));
tmpTag->setStringValue(buffer, outlen);
*tag = tmpTag;
*lenPtr = length;
DBG(" parse string %s\n", tmpTag->getString()->stringValue().c_str());
@ -605,7 +605,7 @@ EFI_STATUS ParseTagData(CHAR8* buffer, TagStruct* * tag, UINT32* lenPtr)
tmpTag = TagData::getEmptyTag();
//Slice - correction as Apple 2003
// tmpTag->setStringValue(LString8(buffer));
// tmpTag->setStringValue(buffer);
// dmazar: base64 decode data
UINTN len = 0;
UINT8* data = (UINT8 *)Base64DecodeClover(buffer, &len);
@ -632,7 +632,7 @@ EFI_STATUS ParseTagDate(CHAR8* buffer, TagStruct* * tag,UINT32* lenPtr)
tmpTag = TagDate::getEmptyTag();
tmpTag->setDateValue(LString8(buffer, length));
tmpTag->setDateValue(buffer, length);
*tag = tmpTag;
*lenPtr = length;

View File

@ -29,6 +29,10 @@
#define TagStruct_USE_CACHE
//#define TagStruct_COUNT_CACHEHITMISS
#ifdef JIEF_DEBUG
#undef TagStruct_USE_CACHE
#endif
class TagDict;
class TagKey;
class TagString;