If bpf file is not valid then cpp generated file is not
deleted because panic() func is invoked.

Signed-off-by: Vadim Kochan <[email protected]>
---
 bpf_parser.y | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/bpf_parser.y b/bpf_parser.y
index 0959f3d..7582bfc 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));
 
@@ -790,11 +791,14 @@ int compile_filter(char *file, int verbose, int bypass, 
int format,
                }
 
                if (__bpf_validate(&res) == 0) {
-                       if (verbose)
+                       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");
                }
@@ -818,7 +822,8 @@ int compile_filter(char *file, int verbose, int bypass, int 
format,
        if (invoke_cpp)
                unlink(tmp_file);
 
-       return 0;
+exit:
+       return ret;
 }
 
 void yyerror(const char *err)
-- 
2.6.2

-- 
You received this message because you are subscribed to the Google Groups 
"netsniff-ng" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to