From 36b3295df7eaa96863c323dcc094aeb2213e08ac Mon Sep 17 00:00:00 2001 From: john Date: Tue, 3 Dec 2019 04:06:45 -0500 Subject: [PATCH] Fixed minor reporting bug --- ban2fail.c | 20 ++++++++++++++------ ban2fail.h | 1 + obsvTpl.c | 3 +++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/ban2fail.c b/ban2fail.c index decce23..1909d40 100644 --- a/ban2fail.c +++ b/ban2fail.c @@ -89,7 +89,7 @@ struct Global G= { .version= { .major= 0, .minor= 13, - .patch= 1 + .patch= 2 }, .bitTuples.flags= GlobalFlagBitTuples @@ -186,7 +186,7 @@ main(int argc, char **argv) int c, option_ndx= 0; - c= getopt_long(argc, argv, ":a::cst:v", long_options, &option_ndx); + c= getopt_long(argc, argv, ":a::cFst:v", long_options, &option_ndx); if(-1 == c) break; @@ -197,10 +197,6 @@ main(int argc, char **argv) ++errflg; break; - case 'c': - G.flags |= GLB_LIST_CNTRY_FLG; - break; - case 'a': G.flags |= GLB_LIST_ADDR_FLG; if(optarg) { @@ -213,6 +209,14 @@ main(int argc, char **argv) } break; + case 'c': + G.flags |= GLB_LIST_CNTRY_FLG; + break; + + case 'F': + G.flags |= GLB_FLUSH_CACHE_FLG; + break; + case 's': G.flags |= GLB_LIST_SUMMARY_FLG; break; @@ -251,6 +255,7 @@ main(int argc, char **argv) " --help\tprint this usage message.\n" " -a[+]\t\tList results by Address. '+' to perform DNS reverse lookups.\n" " -c\t\tlist results by Country\n" +" -F\t\tFlush the cache\n" " -s\t\tlist Summary results only\n" " -t confFile\tTest confFile, do not apply iptables rules\n" " -v\t\tVerbose information about unrecognized configuration info\n" @@ -335,6 +340,9 @@ main(int argc, char **argv) /* Open our cache, instance file-specific LOGTYPE objects */ { /*=============================================================*/ + if(G.flags & GLB_FLUSH_CACHE_FLG && !access(G.cacheDir, F_OK)) { + ez_rmdir_recursive(G.cacheDir); + } /* Make the directory if needed */ if(access(G.cacheDir, F_OK)) { diff --git a/ban2fail.h b/ban2fail.h index 00b938e..45757f9 100644 --- a/ban2fail.h +++ b/ban2fail.h @@ -69,6 +69,7 @@ enum GlobalFlg_enum { GLB_PRINT_LOGFILE_NAMES_FLG=1<<5, GLB_DNS_LOOKUP_FLG =1<<6, GLB_DNS_FILTER_BAD_FLG =1<<7, + GLB_FLUSH_CACHE_FLG =1<<8, GLB_LONG_LISTING_MASK = GLB_LIST_CNTRY_FLG|GLB_LIST_ADDR_FLG }; diff --git a/obsvTpl.c b/obsvTpl.c index 60dc287..884c335 100644 --- a/obsvTpl.c +++ b/obsvTpl.c @@ -190,6 +190,9 @@ obsv_load_AddrRPT(struct obsv *self, struct infoTuple *it) assert(self->len < sizeof(lbuf)); unsigned len= MIN(self->len, sizeof(lbuf)-1); + /* Put null terminator in place */ + lbuf[len]= '\0'; + ez_gzseek(it->fh, self->pos, SEEK_SET); ez_gzread(it->fh, lbuf, len); AddrRPT_addLine(it->ar, it->lf, lbuf);