New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
asf: fix GUID reading on big endian platforms #2694
Conversation
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
Codecov Report
@@ Coverage Diff @@
## main #2694 +/- ##
==========================================
- Coverage 63.91% 63.89% -0.02%
==========================================
Files 103 103
Lines 22314 22318 +4
Branches 10800 10801 +1
==========================================
Hits 14261 14261
- Misses 5828 5831 +3
- Partials 2225 2226 +1
|
sounds like this fixes #2597 can you confirm? |
@@ -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()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In other places where I've seen this pattern, a variable gets set to isBigEndianPlatform() and byteSwap gets called as:
data1_ = byteSwap(data1_, bSwap);
data2_ = byteSwap(data2_, bSwap);
data3_ = byteSwap(data3_, bSwap);
It does fix the linked issue. Just tested. |
I don't have a big-endian 64bit mips system, however the fix worked fine on a s390x system. |
@Mergifyio backport 0.28.x |
✅ Backports have been created
|
Setting the initial parts (
data1_
,data2_
,data3_
) from the bytes directly usingmemcpy()
means that they will be interpreted depending on the platform endianness. For example, the initial 4 bytes of the ASF header are0x30
,0x26
,0xB2
,0x75
, which will be read as0x3026B275
on big endian platofrms, 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