]> granicus.if.org Git - file/commitdiff
Don't allow lines with no fields before or after the number of fields has
authorChristos Zoulas <christos@zoulas.com>
Mon, 24 Jun 2019 23:40:03 +0000 (23:40 +0000)
committerChristos Zoulas <christos@zoulas.com>
Mon, 24 Jun 2019 23:40:03 +0000 (23:40 +0000)
been set.

src/is_csv.c

index ea37844e150db1c0d52ed351e99d0dab400c8303..961975d94acda17f0284e3f2efbc71e502a6c534 100644 (file)
@@ -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 <string.h>
@@ -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) {