Fixes to Coverity defects 85010 84878 72752 72742 72719 and 73418.

skygw_utils.cc: Added function is_valid_posix_path that checks if a path is POSIX-compliant.
This commit is contained in:
Markus Makela
2015-01-05 06:05:56 +02:00
parent b3d79f7273
commit ba009e5fd3
9 changed files with 36 additions and 16 deletions

View File

@ -2058,11 +2058,29 @@ size_t get_decimal_len(
return value > 0 ? (size_t) log10 ((double) value) + 1 : 1;
}
/**
* Check if the provided pathname is POSIX-compliant. The valid characters
* are [a-z A-Z 0-9._-].
* @param path A null-terminated string
* @return true if it is a POSIX-compliant pathname, otherwise false
*/
bool is_valid_posix_path(char* path)
{
char* ptr = path;
while (*ptr != '\0')
{
if (isalnum (*ptr) ||
*ptr == '/' ||
*ptr == '.' ||
*ptr == '-' ||
*ptr == '_')
{
ptr++;
}
else
{
return false;
}
}
return true;
}