Security improvements

Improvements include
* adding additional build flags that warn about stack-smashing
and type conversion errors
* run-time checks for valid function input values and adquate
space for the result of arithmetic operations.
* make sure default case for switch statements do something
besides just assert
* disable using env. var. debugging in release mode

Change-Id: I5f048310c5c56e05d9ec31bcc273404d6a0dd646
This commit is contained in:
Chris Freehill
2020-01-14 15:37:52 -06:00
parent fe4f7ed4a1
commit d00b9ac07d
11 changed files with 278 additions and 89 deletions
+7 -8
View File
@@ -140,17 +140,16 @@ int ReadSysfsStr(std::string path, std::string *retStr) {
return ret;
}
bool IsInteger(const std::string & n_str)
{
if(n_str.empty() || ((!isdigit(n_str[0])) && (n_str[0] != '-')
bool IsInteger(const std::string & n_str) {
if (n_str.empty() || ((!isdigit(n_str[0])) && (n_str[0] != '-')
&& (n_str[0] != '+'))) {
return false;
}
return false;
}
char * tmp;
strtol(n_str.c_str(), &tmp, 10);
char * tmp;
strtol(n_str.c_str(), &tmp, 10);
return (*tmp == 0);
return (*tmp == 0);
}
} // namespace smi
} // namespace amd