summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlouist103 <35883445+louist103@users.noreply.github.com>2022-11-07 12:17:49 -0500
committerGitHub <noreply@github.com>2022-11-07 12:17:49 -0500
commit2b5ced906972348fa4e14ba63c3fd1ac680051af (patch)
tree8c887d1657b7ab0234eb9908d531836869dbb87d
parent78fdac56498f674eba2692e075d415a12cb4a31f (diff)
parent622804013f9fb039266788c43d677724af596d8c (diff)
Merge pull request #268 from louist103/offsetChecks
Check for non hex in asset offset.
-rw-r--r--ZAPD/ZFile.cpp7
-rw-r--r--ZAPDUtils/Utils/StringHelper.h5
2 files changed, 11 insertions, 1 deletions
diff --git a/ZAPD/ZFile.cpp b/ZAPD/ZFile.cpp
index 6f22c88..60382f6 100644
--- a/ZAPD/ZFile.cpp
+++ b/ZAPD/ZFile.cpp
@@ -213,7 +213,12 @@ void ZFile::ParseXML(tinyxml2::XMLElement* reader, const std::string& filename)
// Check for repeated attributes.
if (offsetXml != nullptr)
{
- rawDataIndex = strtol(StringHelper::Split(offsetXml, "0x")[1].c_str(), NULL, 16);
+ std::string offsetStr = StringHelper::Split(offsetXml, "0x")[1];
+ if (!StringHelper::HasOnlyHexDigits(offsetStr))
+ {
+ HANDLE_ERROR(WarningType::InvalidXML, StringHelper::Sprintf("Invalid offset %s entered", offsetStr.c_str()), "");
+ }
+ rawDataIndex = strtol(offsetStr.c_str(), NULL, 16);
if (offsetSet.find(offsetXml) != offsetSet.end())
{
diff --git a/ZAPDUtils/Utils/StringHelper.h b/ZAPDUtils/Utils/StringHelper.h
index 2289927..693813c 100644
--- a/ZAPDUtils/Utils/StringHelper.h
+++ b/ZAPDUtils/Utils/StringHelper.h
@@ -105,6 +105,11 @@ public:
{
return std::all_of(str.begin(), str.end(), ::isdigit);
}
+
+ static bool HasOnlyHexDigits(const std::string& str)
+ {
+ return std::all_of(str.begin(), str.end(), ::isxdigit);
+ }
static std::string ToUpper(const std::string& str)
{