ASF: Skip attributes with invalid data type (#1429)

This commit is contained in:
Urs Fleisch
2026-08-27 17:35:54 +02:00
committed by GitHub
parent d391029695
commit 3672fa6dd2
2 changed files with 22 additions and 11 deletions
+13 -5
View File
@@ -26,6 +26,7 @@
#include "asfattribute.h"
#include "tdebug.h"
#include "tutils.h"
#include "asffile.h"
#include "asfutils.h"
@@ -171,26 +172,27 @@ ASF::Attribute ASF::Attribute::fromGuid(const ByteVector& guid)
String ASF::Attribute::parse(ASF::File &file, int kind)
{
unsigned int size, nameLength;
unsigned int size;
unsigned short nameLength, dataType;
String name;
d->pictureValue = Picture::fromInvalid();
// extended content descriptor
if(kind == 0) {
nameLength = readWORD(&file);
name = readString(&file, nameLength);
d->type = static_cast<ASF::Attribute::AttributeTypes>(readWORD(&file));
dataType = readWORD(&file);
size = readWORD(&file);
}
// metadata & metadata library
else {
int temp = readWORD(&file);
const unsigned short temp = readWORD(&file);
// metadata library
if(kind == 2) {
d->language = temp;
}
d->stream = readWORD(&file);
nameLength = readWORD(&file);
d->type = static_cast<ASF::Attribute::AttributeTypes>(readWORD(&file));
dataType = readWORD(&file);
size = readDWORD(&file);
name = readString(&file, nameLength);
}
@@ -199,7 +201,7 @@ String ASF::Attribute::parse(ASF::File &file, int kind)
debug("ASF::Attribute::parse() -- Value larger than 64kB");
}
switch(d->type) {
switch(dataType) {
case WordType:
d->numericValue = readWORD(&file);
break;
@@ -229,7 +231,13 @@ String ASF::Attribute::parse(ASF::File &file, int kind)
case GuidType:
d->byteVectorValue = file.readBlock(size);
break;
default:
debug(Utils::formatString(
"ASF::Attribute::parse() -- Unknown data type 0x%hx", dataType));
return {};
}
d->type = static_cast<AttributeTypes>(dataType);
if(d->type == BytesType && name == "WM/Picture") {
d->pictureValue.parse(d->byteVectorValue);
+9 -6
View File
@@ -330,8 +330,9 @@ void ASF::File::FilePrivate::ExtendedContentDescriptionObject::parse(ASF::File *
}
ASF::Attribute attribute;
String name = attribute.parse(*file);
file->d->tag->addAttribute(name, attribute);
if(String name = attribute.parse(*file); !name.isEmpty()) {
file->d->tag->addAttribute(name, attribute);
}
if(file->tell() > end) {
file->setValid(false);
@@ -369,8 +370,9 @@ void ASF::File::FilePrivate::MetadataObject::parse(ASF::File *file, long long si
}
ASF::Attribute attribute;
String name = attribute.parse(*file, 1);
file->d->tag->addAttribute(name, attribute);
if(String name = attribute.parse(*file, 1); !name.isEmpty()) {
file->d->tag->addAttribute(name, attribute);
}
if(file->tell() > end) {
file->setValid(false);
@@ -408,8 +410,9 @@ void ASF::File::FilePrivate::MetadataLibraryObject::parse(ASF::File *file, long
}
ASF::Attribute attribute;
String name = attribute.parse(*file, 2);
file->d->tag->addAttribute(name, attribute);
if(String name = attribute.parse(*file, 2); !name.isEmpty()) {
file->d->tag->addAttribute(name, attribute);
}
if(file->tell() > end) {
file->setValid(false);