From fac703d878e45b227b5e938849466fe58d180253 Mon Sep 17 00:00:00 2001 From: lns Date: Sat, 20 May 2023 17:16:31 +0200 Subject: Improved helper scripts to be more restrictive. Signed-off-by: lns --- utils/ipaddr2list.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'utils/ipaddr2list.py') diff --git a/utils/ipaddr2list.py b/utils/ipaddr2list.py index 5b2b10bf3..ebf3cf2e6 100755 --- a/utils/ipaddr2list.py +++ b/utils/ipaddr2list.py @@ -40,8 +40,10 @@ print("""/* print("static ndpi_network "+proto.lower()+"_protocol_list[] = {") +lines = 0 with open(sys.argv[1]) as fp: for cnt, line in enumerate(fp): + lines += 1 line = line.rstrip() if(line != ""): @@ -60,3 +62,7 @@ with open(sys.argv[1]) as fp: print(" /* End */") print(" { 0x0, 0, 0 }") print("};") + +if lines == 0: + sys.stderr.write(f'File {sys.argv[1]} is empty.\n') + sys.exit(1) -- cgit v1.2.3