tracing: Have zero size length in filter logic be full string
As strings in trace events may not have a nul terminating character, the filter string compares use the defined string length for the field for the compares. The trace_marker records data slightly different than do normal events. It's size is zero, meaning that the string is the rest of the array, and that the string also ends with '\0'. If the size is zero, assume that the string is nul terminated and read the string in question as is. Reviewed-by: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
This commit is contained in:
parent
3dd8095368
commit
10f20e9f9d
|
@ -750,31 +750,32 @@ static int filter_pred_none(struct filter_pred *pred, void *event)
|
||||||
*
|
*
|
||||||
* Note:
|
* Note:
|
||||||
* - @str might not be NULL-terminated if it's of type DYN_STRING
|
* - @str might not be NULL-terminated if it's of type DYN_STRING
|
||||||
* or STATIC_STRING
|
* or STATIC_STRING, unless @len is zero.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int regex_match_full(char *str, struct regex *r, int len)
|
static int regex_match_full(char *str, struct regex *r, int len)
|
||||||
{
|
{
|
||||||
if (strncmp(str, r->pattern, len) == 0)
|
/* len of zero means str is dynamic and ends with '\0' */
|
||||||
return 1;
|
if (!len)
|
||||||
return 0;
|
return strcmp(str, r->pattern) == 0;
|
||||||
|
|
||||||
|
return strncmp(str, r->pattern, len) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int regex_match_front(char *str, struct regex *r, int len)
|
static int regex_match_front(char *str, struct regex *r, int len)
|
||||||
{
|
{
|
||||||
if (len < r->len)
|
if (len && len < r->len)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (strncmp(str, r->pattern, r->len) == 0)
|
return strncmp(str, r->pattern, r->len) == 0;
|
||||||
return 1;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int regex_match_middle(char *str, struct regex *r, int len)
|
static int regex_match_middle(char *str, struct regex *r, int len)
|
||||||
{
|
{
|
||||||
if (strnstr(str, r->pattern, len))
|
if (!len)
|
||||||
return 1;
|
return strstr(str, r->pattern) != NULL;
|
||||||
return 0;
|
|
||||||
|
return strnstr(str, r->pattern, len) != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int regex_match_end(char *str, struct regex *r, int len)
|
static int regex_match_end(char *str, struct regex *r, int len)
|
||||||
|
|
Loading…
Reference in New Issue