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:
@ -20,6 +20,7 @@
|
||||
|
||||
#include <math.h>
|
||||
#include <stdbool.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#define SECOND_USEC (1024*1024L)
|
||||
#define MSEC_USEC (1024L)
|
||||
|
||||
@ -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;
|
||||
}
|
||||
@ -198,7 +198,7 @@ size_t get_decimal_len(size_t s);
|
||||
char* replace_literal(char* haystack,
|
||||
const char* needle,
|
||||
const char* replacement);
|
||||
|
||||
bool is_valid_posix_path(char* path);
|
||||
EXTERN_C_BLOCK_END
|
||||
|
||||
#endif /* SKYGW_UTILS_H */
|
||||
|
||||
Reference in New Issue
Block a user