From c52d6b8ad6343f30943a4548fbc2e8925bae6482 Mon Sep 17 00:00:00 2001 From: leitner Date: Sun, 2 Sep 2018 10:49:05 +0000 Subject: [PATCH] add clang static analyzer target in makefile free hash table in addindex (not strictly necessary but shuts up memory leak false positives) add openat to seccomp jail so glibc compiled tinyldap works, too --- Makefile | 3 +++ addindex.c | 7 +++++++ tinyldap.c | 25 +++++++++++++++++++++---- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index b9bc581..3f66ad0 100644 --- a/Makefile +++ b/Makefile @@ -211,6 +211,9 @@ privatekey.pem: windoze: $(MAKE) DIET= CROSS=i686-mingw32- asn1dump +static-analyzer: + /opt/llvm/bin/scan-build --use-cc=/opt/llvm/bin/clang make DIET= -j4 + fmt_tls_alert.o: fmt_tls_alert.c tinytls.h asn1.h fmt_tls_alert_pkt.o: fmt_tls_alert_pkt.c tinytls.h asn1.h fmt_tls_clienthello.o: fmt_tls_clienthello.c tinytls.h asn1.h diff --git a/addindex.c b/addindex.c index bf12c18..763f8d9 100644 --- a/addindex.c +++ b/addindex.c @@ -310,6 +310,9 @@ int main(int argc,char* argv[]) { buffer_putulong(buffer_1,cmaxcoll); buffer_putsflush(buffer_1," chains).\n"); + if (!nmincoll) + die(111,"can''t happen error: table size zero!?"); + maxtabsize=nmincoll; memset(tab,0,maxtabsize*sizeof(struct htentry)); @@ -372,6 +375,10 @@ int main(int argc,char* argv[]) { } } + for (j=0; jx; - if (!f) return 1; + if (!f) { + emptyset(b); + return 1; + } if (f->type==EQUAL) { /* prefer a hash index if there is one */ uint32 ofs; @@ -842,7 +845,7 @@ static int useindex(struct Filter* f,struct bitfield* b) { return 1; } case SUBSTRING: - if (f->substrings->substrtype!=prefix) return 0; + if (f->substrings->substrtype!=prefix) { emptyset(b); return 0; } { uint32 ofs; for (ofs=indices_offset+record_count*4; ofs