mirror of
https://github.com/acidanthera/audk.git
synced 2025-04-08 17:05:09 +02:00
NetworkPkg/DxeNetLib: Fix unaligned access in NetblockChecksum
Into this routine the caller passes different data structures with different alignment that is why casting bulk pointer to UINT16 violates strict aliasing rule.
This commit is contained in:
parent
4c66e6a87e
commit
7836b3768f
@ -1618,20 +1618,12 @@ NetblockChecksum (
|
||||
)
|
||||
{
|
||||
register UINT32 Sum;
|
||||
UINT32 BulkPtr;
|
||||
|
||||
Sum = 0;
|
||||
|
||||
//
|
||||
// Add left-over byte, if any
|
||||
//
|
||||
if (Len % 2 != 0) {
|
||||
Sum += *(Bulk + Len - 1);
|
||||
}
|
||||
|
||||
while (Len > 1) {
|
||||
Sum += *(UINT16 *)Bulk;
|
||||
Bulk += 2;
|
||||
Len -= 2;
|
||||
for (BulkPtr = 0; BulkPtr < Len; BulkPtr++, Bulk++) {
|
||||
Sum += ((*Bulk) << ((BulkPtr & 1U) * 8U));
|
||||
}
|
||||
|
||||
//
|
||||
|
Loading…
x
Reference in New Issue
Block a user