ShellPkg: Fix conditionally uninitialized variables
Fixes CodeQL alerts for CWE-457: https://cwe.mitre.org/data/definitions/457.html Cc: Erich McMillan <emcmillan@microsoft.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Michael Kubacki <mikuback@linux.microsoft.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Co-authored-by: Erich McMillan <emcmillan@microsoft.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com> Reviewed-by: Oliver Smith-Denny <osd@smith-denny.com>
This commit is contained in:
committed by
mergify[bot]
parent
7dc182ed1e
commit
11dd44dfbe
@@ -508,9 +508,10 @@ ShellCommandRunConnect (
|
||||
Count = ShellCommandLineGetCount (Package);
|
||||
|
||||
if (Param1 != NULL) {
|
||||
Status = ShellConvertStringToUint64 (Param1, &Intermediate, TRUE, FALSE);
|
||||
Handle1 = ConvertHandleIndexToHandle ((UINTN)Intermediate);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Status = ShellConvertStringToUint64 (Param1, &Intermediate, TRUE, FALSE);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Handle1 = ConvertHandleIndexToHandle ((UINTN)Intermediate);
|
||||
} else {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"connect", Param1);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
@@ -519,9 +520,10 @@ ShellCommandRunConnect (
|
||||
}
|
||||
|
||||
if (Param2 != NULL) {
|
||||
Status = ShellConvertStringToUint64 (Param2, &Intermediate, TRUE, FALSE);
|
||||
Handle2 = ConvertHandleIndexToHandle ((UINTN)Intermediate);
|
||||
if (EFI_ERROR (Status)) {
|
||||
Status = ShellConvertStringToUint64 (Param2, &Intermediate, TRUE, FALSE);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
Handle2 = ConvertHandleIndexToHandle ((UINTN)Intermediate);
|
||||
} else {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"connect", Param2);
|
||||
ShellStatus = SHELL_INVALID_PARAMETER;
|
||||
}
|
||||
|
@@ -160,12 +160,17 @@ ShellCommandRunDisconnect (
|
||||
Param1 = ShellCommandLineGetRawValue (Package, 1);
|
||||
Param2 = ShellCommandLineGetRawValue (Package, 2);
|
||||
Param3 = ShellCommandLineGetRawValue (Package, 3);
|
||||
ShellConvertStringToUint64 (Param1, &Intermediate1, TRUE, FALSE);
|
||||
Handle1 = Param1 != NULL ? ConvertHandleIndexToHandle ((UINTN)Intermediate1) : NULL;
|
||||
ShellConvertStringToUint64 (Param2, &Intermediate2, TRUE, FALSE);
|
||||
Handle2 = Param2 != NULL ? ConvertHandleIndexToHandle ((UINTN)Intermediate2) : NULL;
|
||||
ShellConvertStringToUint64 (Param3, &Intermediate3, TRUE, FALSE);
|
||||
Handle3 = Param3 != NULL ? ConvertHandleIndexToHandle ((UINTN)Intermediate3) : NULL;
|
||||
if (!EFI_ERROR (ShellConvertStringToUint64 (Param1, &Intermediate1, TRUE, FALSE))) {
|
||||
Handle1 = Param1 != NULL ? ConvertHandleIndexToHandle ((UINTN)Intermediate1) : NULL;
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (ShellConvertStringToUint64 (Param2, &Intermediate2, TRUE, FALSE))) {
|
||||
Handle2 = Param2 != NULL ? ConvertHandleIndexToHandle ((UINTN)Intermediate2) : NULL;
|
||||
}
|
||||
|
||||
if (!EFI_ERROR (ShellConvertStringToUint64 (Param3, &Intermediate3, TRUE, FALSE))) {
|
||||
Handle3 = Param3 != NULL ? ConvertHandleIndexToHandle ((UINTN)Intermediate3) : NULL;
|
||||
}
|
||||
|
||||
if ((Param1 != NULL) && (Handle1 == NULL)) {
|
||||
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"disconnect", Param1);
|
||||
|
@@ -438,25 +438,22 @@ ShellCommandRunDrvDiag (
|
||||
ControllerHandleStr = ShellCommandLineGetRawValue (Package, 2);
|
||||
ChildHandleStr = ShellCommandLineGetRawValue (Package, 3);
|
||||
|
||||
if (DriverHandleStr == NULL) {
|
||||
Handle1 = NULL;
|
||||
} else {
|
||||
ShellConvertStringToUint64 (DriverHandleStr, &Intermediate, TRUE, FALSE);
|
||||
if ((DriverHandleStr != NULL) && !EFI_ERROR (ShellConvertStringToUint64 (DriverHandleStr, &Intermediate, TRUE, FALSE))) {
|
||||
Handle1 = ConvertHandleIndexToHandle ((UINTN)Intermediate);
|
||||
} else {
|
||||
Handle1 = NULL;
|
||||
}
|
||||
|
||||
if (ControllerHandleStr == NULL) {
|
||||
Handle2 = NULL;
|
||||
} else {
|
||||
ShellConvertStringToUint64 (ControllerHandleStr, &Intermediate, TRUE, FALSE);
|
||||
if ((ControllerHandleStr != NULL) && !EFI_ERROR (ShellConvertStringToUint64 (ControllerHandleStr, &Intermediate, TRUE, FALSE))) {
|
||||
Handle2 = ConvertHandleIndexToHandle ((UINTN)Intermediate);
|
||||
} else {
|
||||
Handle2 = NULL;
|
||||
}
|
||||
|
||||
if (ChildHandleStr == NULL) {
|
||||
Handle3 = NULL;
|
||||
} else {
|
||||
ShellConvertStringToUint64 (ChildHandleStr, &Intermediate, TRUE, FALSE);
|
||||
if ((ChildHandleStr != NULL) && !EFI_ERROR (ShellConvertStringToUint64 (ChildHandleStr, &Intermediate, TRUE, FALSE))) {
|
||||
Handle3 = ConvertHandleIndexToHandle ((UINTN)Intermediate);
|
||||
} else {
|
||||
Handle3 = NULL;
|
||||
}
|
||||
|
||||
Status = DoDiagnostics (
|
||||
|
Reference in New Issue
Block a user