[systemd-sonic-generator] replace sscanf with strtol (#15357)

#### Why I did it
Avoid 'sscanf()' for number conversions. Its use can lead to undefined behavior, slow processing, and integer overflows. Instead prefer the 'strto*()' family of functions.

#### How I did it
replace sscanf with strtol
#### How to verify it
Manual test
This commit is contained in:
Mai Bui 2023-06-22 16:16:11 -04:00 committed by GitHub
parent 475fe27c0b
commit fca3458ae7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -569,7 +569,7 @@ int get_num_of_asic() {
str_num_asic = strtok_r(NULL, "=", &saveptr);
strip_trailing_newline(str_num_asic);
if (str_num_asic != NULL){
sscanf(str_num_asic, "%d",&num_asic);
num_asic = strtol(str_num_asic, NULL, 10);
}
break;
}