From: Christos Zoulas Date: Mon, 24 Jun 2019 23:40:03 +0000 (+0000) Subject: Don't allow lines with no fields before or after the number of fields has X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=933e483a2599b98c764aa38e43c3f557feb674e6;p=file Don't allow lines with no fields before or after the number of fields has been set. --- diff --git a/src/is_csv.c b/src/is_csv.c index ea37844e..961975d9 100644 --- a/src/is_csv.c +++ b/src/is_csv.c @@ -32,7 +32,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: is_csv.c,v 1.2 2019/06/24 20:07:36 christos Exp $") +FILE_RCSID("@(#)$File: is_csv.c,v 1.3 2019/06/24 23:40:03 christos Exp $") #endif #include @@ -110,10 +110,10 @@ csv_parse(const unsigned char *uc, const unsigned char *ue) if (nl == CSV_LINES) return tf != 0 && tf == nf; #endif - if (nf == 0) - break; - if (tf == 0) { + // First time and no fields, give up + if (nf == 0) + return 0; // First time, set the number of fields tf = nf; } else if (tf != nf) {