[SWDEV-533349] codeQL erors in amdsmi source code (#588)

Signed-off-by: Saeed, Oosman <Oosman.Saeed@amd.com>
This commit is contained in:
Saeed, Oosman
2025-08-05 20:17:21 -05:00
committed by GitHub
parent fc5ea762b3
commit 753a5ea326
3 changed files with 12 additions and 7 deletions
+7 -2
View File
@@ -7360,9 +7360,14 @@ rsmi_event_notification_get(int timeout_ms,
* Both event are expressed in hex.
* information is a string
*/
char message[MAX_EVENT_NOTIFICATION_MSG_SIZE];
char message[MAX_EVENT_NOTIFICATION_MSG_SIZE] = {0};
// parse the line here for event_number and rest of message_information
sscanf(event_in, "%x %[^\n]\n", &event, message);
// sscanf(event_in, "%x %[^\n]\n", &event, message); // This is unsafe code and flagged by codeql. Replace with iss below:
std::istringstream iss(event_in);
iss >> std::hex >> event;
std::string message_str;
std::getline(iss >> std::ws, message_str);
snprintf(message, sizeof(message), "%s", message_str.c_str());
// parse message based on event received
switch (event){