X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FLibrary%2FDxeNetLib%2FDxeNetLib.c;h=b8544b89ab8d3f5bee7b5e94c1eb12f615b170c2;hp=37b89f5ca408c98111cb5a180f8b834d43646660;hb=29788f178e48fa5ffe7d3262d73c9548e9285d2d;hpb=9f5ca5efbd0bb00c9d3577b95e6322e85cb0b118 diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c index 37b89f5ca4..b8544b89ab 100644 --- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c +++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c @@ -637,7 +637,9 @@ NetGetIpClass ( ASSERT if NetMask is zero. - If all bits of the host address of IP are 0 or 1, IP is also not a valid unicast address. + If all bits of the host address of IP are 0 or 1, IP is also not a valid unicast address, + except when the originator is one of the endpoints of a point-to-point link with a 31-bit + mask (RFC3021). @param[in] Ip The IP to check against. @param[in] NetMask The mask of the IP. @@ -657,9 +659,13 @@ NetIp4IsUnicast ( if (Ip == 0 || IP4_IS_LOCAL_BROADCAST (Ip)) { return FALSE; } - - if (((Ip &~NetMask) == ~NetMask) || ((Ip &~NetMask) == 0)) { - return FALSE; + + if (NetGetMaskLength (NetMask) != 31) { + if (((Ip &~NetMask) == ~NetMask) || ((Ip &~NetMask) == 0)) { + return FALSE; + } + } else { + return TRUE; } return TRUE; @@ -872,7 +878,7 @@ NetRandomInitSeed ( UINT64 MonotonicCount; gRT->GetTime (&Time, NULL); - Seed = (~Time.Hour << 24 | Time.Day << 16 | Time.Minute << 8 | Time.Second); + Seed = (Time.Hour << 24 | Time.Day << 16 | Time.Minute << 8 | Time.Second); Seed ^= Time.Nanosecond; Seed ^= Time.Year << 7; @@ -2225,6 +2231,7 @@ NetLibGetMacString ( UINT16 VlanId; CHAR16 *String; UINTN Index; + UINTN BufferSize; ASSERT (MacString != NULL); @@ -2241,7 +2248,8 @@ NetLibGetMacString ( // If VLAN is configured, it will need extra 5 characters like "\0005". // Plus one unicode character for the null-terminator. // - String = AllocateZeroPool ((2 * HwAddressSize + 5 + 1) * sizeof (CHAR16)); + BufferSize = (2 * HwAddressSize + 5 + 1) * sizeof (CHAR16); + String = AllocateZeroPool (BufferSize); if (String == NULL) { return EFI_OUT_OF_RESOURCES; } @@ -2252,7 +2260,14 @@ NetLibGetMacString ( // HwAddress = &MacAddress.Addr[0]; for (Index = 0; Index < HwAddressSize; Index++) { - String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, *(HwAddress++), 2); + UnicodeValueToStringS ( + String, + BufferSize - ((UINTN)String - (UINTN)*MacString), + PREFIX_ZERO | RADIX_HEX, + *(HwAddress++), + 2 + ); + String += StrnLenS (String, (BufferSize - ((UINTN)String - (UINTN)*MacString)) / sizeof (CHAR16)); } // @@ -2261,7 +2276,14 @@ NetLibGetMacString ( VlanId = NetLibGetVlanId (ServiceHandle); if (VlanId != 0) { *String++ = L'\\'; - String += UnicodeValueToString (String, PREFIX_ZERO | RADIX_HEX, VlanId, 4); + UnicodeValueToStringS ( + String, + BufferSize - ((UINTN)String - (UINTN)*MacString), + PREFIX_ZERO | RADIX_HEX, + VlanId, + 4 + ); + String += StrnLenS (String, (BufferSize - ((UINTN)String - (UINTN)*MacString)) / sizeof (CHAR16)); } // @@ -2979,7 +3001,7 @@ NetLibGetSystemGuid ( return EFI_NOT_FOUND; } Smbios.Hdr = (SMBIOS_STRUCTURE *) (UINTN) SmbiosTable->TableAddress; - SmbiosEnd.Raw = (UINT8 *) (UINTN) (SmbiosTable->TableAddress + SmbiosTable->TableLength); + SmbiosEnd.Raw = (UINT8 *) ((UINTN) SmbiosTable->TableAddress + SmbiosTable->TableLength); } do {