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:
Savva Mitrofanov 2025-03-07 15:47:24 +03:00 committed by Mikhail Krichanov
parent 4c66e6a87e
commit 7836b3768f

View File

@ -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));
}
//