Skip to content

Commit

Permalink
Fix unbounded write of sscanf
Browse files Browse the repository at this point in the history
Format string "%s" that does not control the length of data
written may overflow.
  • Loading branch information
szsam committed Apr 22, 2023
1 parent 8de2b4d commit 0a5cad7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/stlink-lib/chipid.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void process_chipfile(char *fname) {
(strncmp(buf, " ", strlen(" ")) == 0))
continue; // ignore empty lines

sscanf(buf, "%s %s", word, value);
sscanf(buf, "%63s %63s", word, value);

if (strcmp(word, "dev_type") == 0) {
buf[strlen(buf) - 1] = 0; // chomp newline
Expand Down

0 comments on commit 0a5cad7

Please sign in to comment.