Skip to content

Commit

Permalink
Rework line_pulse_duration_option_parse()
Browse files Browse the repository at this point in the history
Introduce proper sscanf() checks.
  • Loading branch information
lundmar committed Apr 14, 2024
1 parent 9744fca commit 76a7a56
Showing 1 changed file with 27 additions and 25 deletions.
52 changes: 27 additions & 25 deletions src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,34 +176,36 @@ void line_pulse_duration_option_parse(const char *arg)
char keyname[11];
unsigned int value;

if (sscanf(token, "%10[^=]=%d", keyname, &value) != 2)
if (sscanf(token, "%10[^=]=%d", keyname, &value) == 2)
{
token_found = false;
}

if (!strcmp(keyname, "DTR"))
{
option.dtr_pulse_duration = value;
}
else if (!strcmp(keyname, "RTS"))
{
option.rts_pulse_duration = value;
}
else if (!strcmp(keyname, "CTS"))
{
option.cts_pulse_duration = value;
}
else if (!strcmp(keyname, "DSR"))
{
option.dsr_pulse_duration = value;
}
else if (!strcmp(keyname, "DCD"))
{
option.dcd_pulse_duration = value;
if (!strcmp(keyname, "DTR"))
{
option.dtr_pulse_duration = value;
}
else if (!strcmp(keyname, "RTS"))
{
option.rts_pulse_duration = value;
}
else if (!strcmp(keyname, "CTS"))
{
option.cts_pulse_duration = value;
}
else if (!strcmp(keyname, "DSR"))
{
option.dsr_pulse_duration = value;
}
else if (!strcmp(keyname, "DCD"))
{
option.dcd_pulse_duration = value;
}
else if (!strcmp(keyname, "RI"))
{
option.ri_pulse_duration = value;
}
}
else if (!strcmp(keyname, "RI"))
else
{
option.ri_pulse_duration = value;
token_found = false;
}
}
else
Expand Down

0 comments on commit 76a7a56

Please sign in to comment.