From d65a9c47ac12ca0823a8e1b0ec2c6f52447011f7 Mon Sep 17 00:00:00 2001 From: Vadim Kochan Date: Sun, 15 Nov 2015 23:16:37 +0200 Subject: bpfc: Do not panic if bpf file is not valid If bpf file is not valid then cpp generated file is not deleted because panic() func is invoked. Signed-off-by: Vadim Kochan [tk: Move exit label to the correct place] Signed-off-by: Tobias Klauser --- bpf_parser.y | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'bpf_parser.y') diff --git a/bpf_parser.y b/bpf_parser.y index 0959f3d..8c09639 100644 --- a/bpf_parser.y +++ b/bpf_parser.y @@ -739,6 +739,7 @@ int compile_filter(char *file, int verbose, int bypass, int format, int i; struct sock_fprog res; char tmp_file[128]; + int ret = 0; memset(tmp_file, 0, sizeof(tmp_file)); @@ -792,9 +793,12 @@ int compile_filter(char *file, int verbose, int bypass, int format, if (__bpf_validate(&res) == 0) { if (verbose) printf("Semantic error! BPF validation failed!\n"); - else - panic("Semantic error! BPF validation failed! " - "Try -V for debugging output!\n"); + else { + printf("Semantic error! BPF validation failed! " + "Try -V for debugging output!\n"); + ret = 1; + goto exit; + } } else if (verbose) { printf("is runnable!\n"); } @@ -815,10 +819,11 @@ int compile_filter(char *file, int verbose, int bypass, int format, if (yyin != stdin) fclose(yyin); +exit: if (invoke_cpp) unlink(tmp_file); - return 0; + return ret; } void yyerror(const char *err) -- cgit v1.2.3-54-g00ecf