Skip to content

Commit

Permalink
asf: fix GUID reading on big endian platforms
Browse files Browse the repository at this point in the history
Setting the initial parts (data1_, data2_, data3_) from the bytes
directly using memcpy() means that they will be interpreted depending
on the platform endianness. For example, the initial 4 bytes of the ASF
header are 0x30, 0x26, 0xB2, 0x75, which will be read as 0x3026B275 on
big endian platforms, never matching the actual GUID (0x75B22630), which
is always specified in little endian format.

Hence, when reading a GUID from data, make sure to turn the GUID parts
to little endian. This fixes the reading of ASF files on big endian
platforms.

Fixes commit bed8d3d
  • Loading branch information
pinotree committed Jul 16, 2023
1 parent 7473b4a commit 235a117
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/asfvideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ AsfVideo::GUIDTag::GUIDTag(const uint8_t* bytes) {
memcpy(&data2_, bytes + DWORD, WORD);
memcpy(&data3_, bytes + DWORD + WORD, WORD);
std::copy(bytes + QWORD, bytes + 2 * QWORD, data4_.begin());
if (isBigEndianPlatform()) {
data1_ = byteSwap(data1_, true);
data2_ = byteSwap(data2_, true);
data3_ = byteSwap(data3_, true);
}
}

std::string AsfVideo::GUIDTag::to_string() {
Expand Down

0 comments on commit 235a117

Please sign in to comment.