Skip to content

Commit fca3458

Browse files
authored
[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
1 parent 475fe27 commit fca3458

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/systemd-sonic-generator/systemd-sonic-generator.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ int get_num_of_asic() {
569569
str_num_asic = strtok_r(NULL, "=", &saveptr);
570570
strip_trailing_newline(str_num_asic);
571571
if (str_num_asic != NULL){
572-
sscanf(str_num_asic, "%d",&num_asic);
572+
num_asic = strtol(str_num_asic, NULL, 10);
573573
}
574574
break;
575575
}

0 commit comments

Comments
 (0)