Skip to content
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

NetworkPkg: More CodeQL fixes #317

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions NetworkPkg/HttpBootDxe/HttpBootConfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -634,16 +634,21 @@ HttpBootConfigFormInit (
STRING_TOKEN (STR_HTTP_BOOT_CONFIG_FORM_HELP),
NULL
);
UnicodeSPrint (MenuString, 128, L"%s (MAC:%s)", OldMenuString, MacString);
HiiSetString (
CallbackInfo->RegisteredHandle,
STRING_TOKEN (STR_HTTP_BOOT_CONFIG_FORM_HELP),
MenuString,
NULL
);
// MU_CHANGE [BEGIN] - CodeQL change
if (OldMenuString != NULL) {
TaylorBeebe marked this conversation as resolved.
Show resolved Hide resolved
UnicodeSPrint (MenuString, 128, L"%s (MAC:%s)", OldMenuString, MacString);
HiiSetString (
CallbackInfo->RegisteredHandle,
STRING_TOKEN (STR_HTTP_BOOT_CONFIG_FORM_HELP),
MenuString,
NULL
);

FreePool (OldMenuString);
}

// MU_CHANGE [END] - CodeQL change
FreePool (MacString);
FreePool (OldMenuString);

CallbackInfo->Initialized = TRUE;
return EFI_SUCCESS;
Expand Down
39 changes: 22 additions & 17 deletions NetworkPkg/Ip4Dxe/Ip4Config2Nv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1358,24 +1358,29 @@ Ip4Config2FormInit (
STRING_TOKEN (STR_IP4_CONFIG2_FORM_HELP),
NULL
);
UnicodeSPrint (MenuString, 128, L"%s (MAC:%s)", OldMenuString, MacString);
HiiSetString (
CallbackInfo->RegisteredHandle,
STRING_TOKEN (STR_IP4_CONFIG2_FORM_HELP),
MenuString,
NULL
);

UnicodeSPrint (PortString, 128, L"MAC:%s", MacString);
HiiSetString (
CallbackInfo->RegisteredHandle,
STRING_TOKEN (STR_IP4_DEVICE_FORM_HELP),
PortString,
NULL
);
// MU_CHANGE [BEGIN] - CodeQL change
if (OldMenuString != NULL && MacString != NULL) {
UnicodeSPrint (MenuString, 128, L"%s (MAC:%s)", OldMenuString, MacString);
HiiSetString (
CallbackInfo->RegisteredHandle,
STRING_TOKEN (STR_IP4_CONFIG2_FORM_HELP),
MenuString,
NULL
);

UnicodeSPrint (PortString, 128, L"MAC:%s", MacString);
HiiSetString (
CallbackInfo->RegisteredHandle,
STRING_TOKEN (STR_IP4_DEVICE_FORM_HELP),
PortString,
NULL
);

FreePool (OldMenuString);
FreePool (MacString);
}

FreePool (MacString);
FreePool (OldMenuString);
// MU_CHANGE [END] - CodeQL change

return EFI_SUCCESS;
}
Expand Down
47 changes: 29 additions & 18 deletions NetworkPkg/Ip6Dxe/Ip6ConfigNv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1413,10 +1413,16 @@ Ip6FormExtractConfig (
goto Exit;
}

// MU_CHANGE [END] - CodeQL change
Size = (StrLen (ConfigRequestHdr) + 32 + 1) * sizeof (CHAR16);
ConfigRequest = AllocateZeroPool (Size);
ASSERT (ConfigRequest != NULL);

if (ConfigRequest == NULL) {
ASSERT (ConfigRequest != NULL);
Status = EFI_OUT_OF_RESOURCES;
goto Exit;
}

// MU_CHANGE [END] - CodeQL change
AllocatedRequest = TRUE;
UnicodeSPrint (
ConfigRequest,
Expand Down Expand Up @@ -2003,23 +2009,28 @@ Ip6ConfigFormInit (
NULL
)
;
UnicodeSPrint (MenuString, 128, L"%s (MAC:%s)", OldMenuString, MacString);
HiiSetString (
CallbackInfo->RegisteredHandle,
STRING_TOKEN (STR_IP6_CONFIG_FORM_HELP),
MenuString,
NULL
);
UnicodeSPrint (PortString, 128, L"MAC:%s", MacString);
HiiSetString (
CallbackInfo->RegisteredHandle,
STRING_TOKEN (STR_IP6_DEVICE_FORM_HELP),
PortString,
NULL
);
if ((OldMenuString != NULL) && (MacString != NULL)) {
UnicodeSPrint (MenuString, 128, L"%s (MAC:%s)", OldMenuString, MacString);
// MU_CHANGE [BEGIN] - CodeQL change
HiiSetString (
CallbackInfo->RegisteredHandle,
STRING_TOKEN (STR_IP6_CONFIG_FORM_HELP),
MenuString,
NULL
);
UnicodeSPrint (PortString, 128, L"MAC:%s", MacString);
HiiSetString (
CallbackInfo->RegisteredHandle,
STRING_TOKEN (STR_IP6_DEVICE_FORM_HELP),
PortString,
NULL
);

FreePool (OldMenuString);
FreePool (MacString);
}

FreePool (MacString);
FreePool (OldMenuString);
// MU_CHANGE [END] - CodeQL change

InitializeListHead (&Instance->Ip6NvData.ManualAddress);
InitializeListHead (&Instance->Ip6NvData.GatewayAddress);
Expand Down
4 changes: 4 additions & 0 deletions NetworkPkg/Ip6Dxe/Ip6Output.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,10 @@ Ip6SelectInterface (
IP6_INTERFACE *IpIf;
BOOLEAN Exist;

// MU_CHANGE [BEGIN] - CodeQL change
IpIf = NULL;
// MU_CHANGE [END] - CodeQL change

NET_CHECK_SIGNATURE (IpSb, IP6_SERVICE_SIGNATURE);
ASSERT (Destination != NULL && Source != NULL);

Expand Down
6 changes: 6 additions & 0 deletions NetworkPkg/Library/DxeHttpIoLib/DxeHttpIoLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,12 @@ HttpIoSendChunkedTransfer (
}

NewHeaders = AllocateZeroPool ((RequestMessage->HeaderCount + AddNewHeader) * sizeof (EFI_HTTP_HEADER));
// MU_CHANGE [BEGIN] - CodeQL change
if (NewHeaders == NULL) {
return EFI_OUT_OF_RESOURCES;
}

// MU_CHANGE [END] - CodeQL change
CopyMem ((VOID *)NewHeaders, (VOID *)RequestMessage->Headers, RequestMessage->HeaderCount * sizeof (EFI_HTTP_HEADER));
if (AddNewHeader == 0) {
//
Expand Down
8 changes: 7 additions & 1 deletion NetworkPkg/TcpDxe/TcpOutput.c
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,14 @@ TcpGetSegmentSock (
// copy data to the segment.
//
Data = NetbufAllocSpace (Nbuf, Len, NET_BUF_TAIL);
ASSERT (Data != NULL);
// MU_CHANGE [BEGIN] - CodeQL change
if (Data == NULL) {
ASSERT (Data != NULL);
NetbufFree (Nbuf);
return NULL;
}

// MU_CHANGE [END] - CodeQL change
DataGet = SockGetDataToSend (Tcb->Sk, 0, Len, Data);
}

Expand Down
8 changes: 7 additions & 1 deletion NetworkPkg/VlanConfigDxe/VlanConfigImpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,13 @@ VlanCallback (
// Get Browser data
//
Configuration = AllocateZeroPool (sizeof (VLAN_CONFIGURATION));
ASSERT (Configuration != NULL);
// MU_CHANGE [BEGIN] - CodeQL change
if (Configuration == NULL) {
ASSERT (Configuration != NULL);
return EFI_OUT_OF_RESOURCES;
}

// MU_CHANGE [END] - CodeQL change
HiiGetBrowserData (&gVlanConfigFormSetGuid, mVlanStorageName, sizeof (VLAN_CONFIGURATION), (UINT8 *)Configuration);

VlanConfig = PrivateData->VlanConfig;
Expand Down