Skip to content

Commit

Permalink
sysdetect: null terminate snprintf strings for CUDA devices
Browse files Browse the repository at this point in the history
  • Loading branch information
gcongiu committed Jul 6, 2023
1 parent 255bf2e commit 7bfd819
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/components/sysdetect/nvidia_gpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ load_cuda_sym( char *status )
if (count >= PAPI_MAX_STR_LEN) {
SUBDBG("Status string truncated.");
}
status[PAPI_MAX_STR_LEN - 1] = 0;
return -1;
}

Expand Down Expand Up @@ -313,6 +314,7 @@ load_nvml_sym( char *status )
if (count >= PAPI_MAX_STR_LEN) {
SUBDBG("Status string truncated.");
}
status[PAPI_MAX_STR_LEN - 1] = 0;
return -1;
}

Expand Down Expand Up @@ -371,6 +373,7 @@ open_nvidia_gpu_dev_type( _sysdetect_dev_type_info_t *dev_type_info )
if (count >= PAPI_MAX_STR_LEN) {
SUBDBG("Status string truncated.");
}
dev_type_info->status[PAPI_MAX_STR_LEN - 1] = 0;
#endif /* HAVE_NVML */

unload_cuda_sym();
Expand All @@ -381,6 +384,7 @@ open_nvidia_gpu_dev_type( _sysdetect_dev_type_info_t *dev_type_info )
if (count >= PAPI_MAX_STR_LEN) {
SUBDBG("Status string truncated.");
}
dev_type_info->status[PAPI_MAX_STR_LEN - 1] = 0;
#endif /* HAVE_CUDA */
}

Expand Down

0 comments on commit 7bfd819

Please sign in to comment.