Skip to content

Commit dbc3838

Browse files
committed
input/csv: stricter input data test for multi column mode
The previous implementation assumed that in multi-column mode each cell communicates exactly one bit of input (a logic channel). But only the first character got tested. Tighten the check, to cover the whole input text. This rejects fully invalid input, as well as increases robustness since multi-bit input like "100" was mistaken as a value of 1 before.
1 parent 1926727 commit dbc3838

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/input/csv.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,13 +446,13 @@ static int parse_multi_columns(char **columns, struct context *inc)
446446

447447
for (i = 0; i < inc->num_channels; i++) {
448448
column = columns[i];
449-
if (column[0] == '1') {
449+
if (strcmp(column, "1") == 0) {
450450
inc->sample_buffer[i / 8] |= (1 << (i % 8));
451451
} else if (!strlen(column)) {
452452
sr_err("Column %zu in line %zu is empty.",
453453
inc->first_channel + i, inc->line_number);
454454
return SR_ERR;
455-
} else if (column[0] != '0') {
455+
} else if (strcmp(column, "0") != 0) {
456456
sr_err("Invalid value '%s' in column %zu in line %zu.",
457457
column, inc->first_channel + i,
458458
inc->line_number);

0 commit comments

Comments
 (0)