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:
@ -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;
|
||||
}
|
Reference in New Issue
Block a user