From 58e8dce449c8b0f1fb36c01de01fe7ed608f44d4 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 2 Sep 2021 15:20:40 +0200 Subject: test-csv: test handling of trailing NUL byte Data after a NUL byte should be ignored. Signed-off-by: Heinrich Schuchardt --- csv.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'csv.c') diff --git a/csv.c b/csv.c index 32780404..18460cd7 100644 --- a/csv.c +++ b/csv.c @@ -77,6 +77,7 @@ parse_csv_data(char *data, char *data_end, size_t n_columns, list_t *list) end = data_end; max = (uintptr_t)end - (uintptr_t)line + (end > line ? 1 : 0); + /* Skip the delimiter(s) of the previous line */ while (max && found) { found = false; for (delim = &delims[0]; max && *delim; delim++) { @@ -87,6 +88,7 @@ parse_csv_data(char *data, char *data_end, size_t n_columns, list_t *list) } } } + /* Find the first delimiter of the current line */ for (delim = &delims[0]; *delim; delim++) { char *tmp = strnchrnul(line, max, *delim); if (tmp < end) -- cgit v1.2.3