On Wed, 3 Nov 2021 17:44:08 +0200 "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@xxxxxxxxx> wrote: > +static int dyn_generic_parse(struct dyn_events_desc *desc, const char *group, > + char *line, struct tracefs_dynevent **ret_dyn) > +{ > + struct tracefs_dynevent *dyn; > + char *format = NULL; > + char *address; > + char *system; > + char *prefix; > + char *event; > + char *sav; > + > + if (strncmp(line, desc->prefix, strlen(desc->prefix))) > + return -1; > + > + prefix = strtok_r(line, ":", &sav); > + if (!prefix) > + return -1; What if the user adds a name for the event? p:name system/event ? > + system = strtok_r(NULL, "/", &sav); > + if (!system) > + return -1; > + event = strtok_r(NULL, " ", &sav); > + if (!event) > + return -1; > + address = strtok_r(NULL, " ", &sav); > + if (!address) > + address = event + strlen(event) + 1; > + else > + format = address + strlen(address) + 1; I'm not sure this is what you want to do, as the above is dangerous. If we have the following string: "p: system/event" event + strlen(event) = '\0' event + strlen(event) + 1 = out-of-bounds; Note, strtok_r() does not need to find the delimiter if the token is the last delimiter. char str[] = "first last"; char *a, *b, *s; a = strtok_r(str, " ", &s); b = strtok_r(NULL, " ", &s); Will result with: a = "first" and b = "last" -- Steve > + > + /* KPROBEs and UPROBEs share the same prefix, check the format */ > + if (desc->type == TRACEFS_DYNEVENT_UPROBE || desc->type == TRACEFS_DYNEVENT_URETPROBE) { > + if (!strchr(address, '/')) > + return -1; > + } > + if (group && strcmp(group, system) != 0) > + return -1; > + > + if (!ret_dyn) > + return 0; > + > + dyn = calloc(1, sizeof(*dyn)); > + if (!dyn) > + return -1; > +