Fix: vpd-tool input validation checks (#368)
vpd-tool with option’s which does not require an object path is
failing with an error ‘Given path is empty’.
As CLI library checks whether value is passed or not for the
selected options by default. If the value is passed as empty string
as “” is not being caught by CLI library.
As CLI library checks whether value is passed or not for the selected
options by default. If the value is passed as empty string as “” is not
being caught by CLI library. Added additional validation that passed
object path, record names are not empty.
Change-Id: I06322c71832b9bc3adbf5ffa3cdc1512c44c591c
Signed-off-by: Anupama B R <anupama.b.r1@ibm.com>
diff --git a/vpd_tool.cpp b/vpd_tool.cpp
index 2e51372..d53a593 100644
--- a/vpd_tool.cpp
+++ b/vpd_tool.cpp
@@ -107,11 +107,16 @@
try
{
- if (objectPath.empty())
+ if (*object && objectPath.empty())
{
throw runtime_error("Given path is empty.");
}
+ if (*record && (recordName.size() != 4))
+ {
+ throw runtime_error("Record " + recordName + " not supported.");
+ }
+
if ((*kw) && (keyword.size() != 2))
{
throw runtime_error("Keyword " + keyword + " not supported.");