#define _STP_STRING_C_
#include "stp_string.h"
-#include <linux/string.h>
/** @file stp_string.c
* @brief Implements string functions.
return n;
}
-/**
- * Compare two strings.
- *
- * @param s1 The first string.
- * @param s2 The second string.
- *
- * @return _stp_strcmp returns an integer less than, equal to, or
- * greater than zero if s1 is found, respectively, to be
- * less than, to match, or be greater than s2. NULL pointers
- * are treated as empty strings.
- */
-static inline int _stp_strcmp(const char *s1 const char *s2)
-{
- if (s1 == NULL && s2 == NULL)
- return 0;
- else if (s1 == NULL)
- return -1;
- else if (s2 == NULL)
- return 1;
- return strcmp(s1, s2);
-}
-
/** @} */
#endif /* _STP_STRING_C_ */
static int _stp_text_str(char *out, const char *in, int inlen, int outlen, int quoted, int user, int buffer);
-static inline int _stp_strcmp(const char *s1 const char *s2);
-
#endif /* _STP_STRING_H_ */
if (path != NULL && offset == 0 && (vm_flags & VM_EXEC)
&& stap_find_vma_map_info(tsk, addr, NULL, NULL, NULL, NULL) != 0) {
for (i = 0; i < _stp_num_modules; i++) {
- // Note we're using _stp_strcmp() instead of
- // strcmp() here. _stp_strcmp() treats NULL
- // string pointers as empty strings. See
- // PR20433 for more details.
- if (_stp_strcmp(path, _stp_modules[i]->path) == 0)
+ // PR20433: papering over possibility of NULL pointers
+ if (strcmp(path ?: "", _stp_modules[i]->path ?: "") == 0)
{
unsigned long vm_start = 0;
unsigned long vm_end = 0;