Skip to content

fix: -d option skips partition ID range validation - #16

Open
andrewwhitecdw wants to merge 1 commit into
NVIDIA:mainfrom
andrewwhitecdw:codequality/fmpm-d-option-skips-partition-id-range
Open

fix: -d option skips partition ID range validation#16
andrewwhitecdw wants to merge 1 commit into
NVIDIA:mainfrom
andrewwhitecdw:codequality/fmpm-d-option-skips-partition-id-range

Conversation

@andrewwhitecdw

Copy link
Copy Markdown

This PR addresses the following issue in fmpm.cpp: -d option skips partition ID range validation.

Changes

  • fmpm.cpp: -d option skips partition ID range validation.

Details

--- a/fmpm.cpp
+++ b/fmpm.cpp
@@ -1,10 +1,14 @@
-        } else if (std::string(argv[i]) == "-d") {
-            operation = SHARED_FABRIC_CMD_DEACTIVATE_PARTITION;
-            if (i + 1 < argc) {
-                partitionId = std::stoul(argv[i + 1]);
-                ++i;
-            } else {
-                std::cerr << "Error: -d option requires partition ID." << std::endl;
-                return FM_ST_BADPARAM;
-            }
-        } else if (std::string(argv[i]) == "--set-activated-list") {
+        } else if (std::string(argv[i]) == "-d") {
+            operation = SHARED_FABRIC_CMD_DEACTIVATE_PARTITION;
+            if (i + 1 < argc) {
+                partitionId = std::stoul(argv[i + 1]);
+                ++i;
+            } else {
+                std::cerr << "Error: -d option requires partition ID." << std::endl;
+                return FM_ST_BADPARAM;
+            }
+            if ( partitionId >= FM_MAX_FABRIC_PARTITIONS ) {
+                std::cout << "Invalid Partition ID." << std::endl;
+                return FM_ST_BADPARAM;
+            }
+        } else if (std::string(argv[i]) == "--set-activated-list") {

Tests

Let me know if you want tests added for this fix or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant