# HG changeset patch # User Mychaela Falconia # Date 1648958102 0 # Node ID 16e259bff02bdfa4a7d0ee65fb66cebbf6331ab2 # Parent 8eb1f60f66760390f94a70bc44d4fa2b707e75c2 fc-pwt-comp: explicitly reject empty input diff -r 8eb1f60f6676 -r 16e259bff02b ringtools/fc-pwt-comp.c --- a/ringtools/fc-pwt-comp.c Sun Apr 03 03:49:48 2022 +0000 +++ b/ringtools/fc-pwt-comp.c Sun Apr 03 03:55:02 2022 +0000 @@ -163,6 +163,8 @@ main(argc, argv) char **argv; { + int nonempty; + if (argc != 3) { fprintf(stderr, "usage: %s src-file bin-file\n", argv[0]); exit(1); @@ -185,6 +187,7 @@ exit(1); } + nonempty = 0; for (lineno = 1; fgets(linebuf, sizeof linebuf, inf); lineno++) { parse_line_into_fields(); if (!nfields) @@ -198,6 +201,12 @@ infname, lineno); exit(1); } + nonempty = 1; } - exit(0); + if (nonempty) + exit(0); + else { + fprintf(stderr, "error: %s is empty\n", infname); + exit(1); + } }