Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse event qualifiers for the Rocm and Cuda components to make sure no excess characters are appended #300

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add a check to parse event qualifiers to make sure no excess characte…
…rs are appended.
  • Loading branch information
Treece Burgess committed Jan 8, 2025
commit 0ff60abf4b4445385ccdbd7f6879ba05ae67c030
7 changes: 6 additions & 1 deletion src/components/cuda/cupti_profiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -2547,7 +2547,12 @@ static int evt_name_to_device(const char *name, int *device)
{
char *p = strstr(name, ":device=");
if (p) {
*device = (int) strtol(p + strlen(":device="), NULL, 10);
char *endPtr;
*device = (int) strtol(p + strlen(":device="), &endPtr, 10);
/* check to make sure no excess characters have been appeneded */
if (*endPtr != '\0') {
return PAPI_ENOEVNT;
}
}
else {
*device = 0;
Expand Down
20 changes: 18 additions & 2 deletions src/components/rocm/roc_profiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,15 @@ evt_name_to_device(const char *name, int *device)
if (!p) {
return PAPI_ENOEVNT;
}
*device = (int) strtol(p + strlen(":device="), NULL, 10);

char *endPtr;
*device = (int) strtol(p + strlen(":device="), &endPtr, 10);
/* check to make sure only qualifiers have been appended */
if (*endPtr != '\0') {
if (strncmp(endPtr, ":instance=", 10) != 0) {
return PAPI_ENOEVNT;
}
}
return PAPI_OK;
}

Expand All @@ -837,7 +845,15 @@ evt_name_to_instance(const char *name, int *instance)
if (!p) {
return PAPI_ENOEVNT;
}
*instance = (int) strtol(p + strlen(":instance="), NULL, 10);

char *endPtr;
*instance = (int) strtol(p + strlen(":instance="), &endPtr, 10);
/* check to make sure only qualifiers have been appended */
if (*endPtr != '\0') {
if (strncmp(endPtr, ":device=", 8) != 0) {
return PAPI_ENOEVNT;
}
}
} else {
if (p) {
return PAPI_ENOEVNT;
Expand Down