From cf9c055c62e8361c7355c6158b8fc83cb264f59a Mon Sep 17 00:00:00 2001 From: William Robinet Date: Wed, 13 May 2015 09:40:52 +0200 Subject: [PATCH 1/7] Add missing comma (introduced by 2d067c26503ace1466d132e7efd9f0ff7885295a) --- ssl/ssl_rec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ssl/ssl_rec.c b/ssl/ssl_rec.c index d598b4f..ffa2e73 100644 --- a/ssl/ssl_rec.c +++ b/ssl/ssl_rec.c @@ -70,7 +70,7 @@ struct ssl_rec_decoder_ { char *digests[]={ "MD5", - "SHA1" + "SHA1", "SHA224", "SHA256", "SHA384", From ca503961865ad1864fda4fe42a441021940b6c21 Mon Sep 17 00:00:00 2001 From: William Robinet Date: Wed, 13 May 2015 09:45:11 +0200 Subject: [PATCH 2/7] Make valgrind/memcheck happy --- base/pcap-snoop.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/base/pcap-snoop.c b/base/pcap-snoop.c index b1bc826..e0c9b62 100644 --- a/base/pcap-snoop.c +++ b/base/pcap-snoop.c @@ -427,6 +427,7 @@ int main(argc,argv) } sprintf(tmp_filter,fmt,filter,filter); + free(filter); filter = tmp_filter; } @@ -451,6 +452,22 @@ int main(argc,argv) printf("\n.ps\n.fi\n"); printf("Cleaning %d remaining connection(s) from connection pool\n", destroy_all_conn()); + + pcap_close(p); + + free(n); + + if(filter) + free(filter); + if(file) + free(file); + if(interface_name) + free(interface_name); + if(SSL_keyfile) + free(SSL_keyfile); + if(SSL_password) + free(SSL_password); + exit(0); } From 03d490159c1e2541b009ac0751795d6e44fa9211 Mon Sep 17 00:00:00 2001 From: William Robinet Date: Wed, 13 May 2015 15:44:38 +0200 Subject: [PATCH 3/7] Do not use uninitialized variable --- common/lib/r_assoc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/lib/r_assoc.c b/common/lib/r_assoc.c index dfa1544..2fee9af 100644 --- a/common/lib/r_assoc.c +++ b/common/lib/r_assoc.c @@ -298,7 +298,7 @@ int r_assoc_copy(newp,old) r_assoc *new; if(!(new=(r_assoc *)calloc(sizeof(r_assoc),1))) - ABORT(r); + ABORT(R_NO_MEMORY); new->size=old->size; new->bits=old->bits; From d1b3a2ac07e549d44e9f7f36be6774c2f93e53cc Mon Sep 17 00:00:00 2001 From: William Robinet Date: Wed, 13 May 2015 16:07:22 +0200 Subject: [PATCH 4/7] Remove dead code --- common/lib/r_bitfield.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/common/lib/r_bitfield.c b/common/lib/r_bitfield.c index cfdbba5..5ca2839 100644 --- a/common/lib/r_bitfield.c +++ b/common/lib/r_bitfield.c @@ -107,7 +107,4 @@ int r_bitfield_isset(set,bit) return(0); return(set->data[word]&(1< Date: Wed, 13 May 2015 16:11:06 +0200 Subject: [PATCH 5/7] "Each invocation of va_start() must be matched by a corresponding invocation of va_end()" --- common/lib/debug.c | 1 + 1 file changed, 1 insertion(+) diff --git a/common/lib/debug.c b/common/lib/debug.c index e275f83..fe19530 100644 --- a/common/lib/debug.c +++ b/common/lib/debug.c @@ -59,6 +59,7 @@ int debug(int class,char *format,...) va_start(ap,format); vfprintf(stderr,format,ap); fprintf(stderr,"\n"); + va_end(ap); return(0); } From 2e0d67c172b43158d882ad64979cd4f19a5296d0 Mon Sep 17 00:00:00 2001 From: William Robinet Date: Mon, 18 May 2015 15:40:22 +0200 Subject: [PATCH 6/7] Fix order of arguments in calls to calloc --- base/network.c | 2 +- base/proto_mod.c | 2 +- base/tcpconn.c | 2 +- base/tcppack.c | 2 +- null/null_analyze.c | 2 +- ssl/ssl_analyze.c | 4 ++-- ssl/ssl_rec.c | 2 +- ssl/ssldecode.c | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/base/network.c b/base/network.c index 563f39f..aeb7ae8 100644 --- a/base/network.c +++ b/base/network.c @@ -153,7 +153,7 @@ int packet_copy(in,out) packet *p=0; - if(!(p=(packet *)calloc(sizeof(packet),1))) + if(!(p=(packet *)calloc(1,sizeof(packet)))) ABORT(R_NO_MEMORY); memcpy(&p->ts,&in->ts,sizeof(struct timeval)); diff --git a/base/proto_mod.c b/base/proto_mod.c index de60272..19f4b31 100644 --- a/base/proto_mod.c +++ b/base/proto_mod.c @@ -58,7 +58,7 @@ int create_proto_handler(mod,ctx,handlerp,conn,first_packet) int r,_status; proto_handler *handler=0; - if(!(handler=(proto_handler *)calloc(sizeof(proto_handler),1))) + if(!(handler=(proto_handler *)calloc(1,sizeof(proto_handler)))) ABORT(R_NO_MEMORY); handler->vtbl=mod->vtbl; if(r=mod->vtbl->create(mod->handle,ctx,conn,&handler->obj, diff --git a/base/tcpconn.c b/base/tcpconn.c index f4d9b14..64535b7 100644 --- a/base/tcpconn.c +++ b/base/tcpconn.c @@ -222,7 +222,7 @@ int copy_tcp_segment_queue(out,in) segment *base=0; for(;in;in=in->next){ - if(!(*out=(segment *)calloc(sizeof(segment),1))) + if(!(*out=(segment *)calloc(1,sizeof(segment)))) ABORT(R_NO_MEMORY); if(!base) base=*out; diff --git a/base/tcppack.c b/base/tcppack.c index 185f73a..4156c73 100644 --- a/base/tcppack.c +++ b/base/tcppack.c @@ -283,7 +283,7 @@ static int process_data_segment(conn,handler,p,stream,direction) break; } - if(!(nseg=(segment *)calloc(sizeof(segment),1))) + if(!(nseg=(segment *)calloc(1,sizeof(segment)))) ABORT(R_NO_MEMORY); if(r=packet_copy(p,&nseg->p)) ABORT(r); diff --git a/null/null_analyze.c b/null/null_analyze.c index c327a61..8792632 100644 --- a/null/null_analyze.c +++ b/null/null_analyze.c @@ -75,7 +75,7 @@ static int create_null_analyzer(handle,ctx,conn,objp,i_addr,i_port,r_addr,r_port null_analyzer *obj=0; static int ctr; - if(!(obj=(null_analyzer *)calloc(sizeof(null_analyzer),1))) + if(!(obj=(null_analyzer *)calloc(1,sizeof(null_analyzer)))) ERETURN(R_NO_MEMORY); obj->num=ctr++; diff --git a/ssl/ssl_analyze.c b/ssl/ssl_analyze.c index 0b7a80a..39465de 100644 --- a/ssl/ssl_analyze.c +++ b/ssl/ssl_analyze.c @@ -241,7 +241,7 @@ static int create_ssl_analyzer(handle,ctx,conn,objp,i_addr,i_port,r_addr,r_port, int r,_status; ssl_obj *obj=0; - if(!(obj=(ssl_obj *)calloc(sizeof(ssl_obj),1))) + if(!(obj=(ssl_obj *)calloc(1,sizeof(ssl_obj)))) ABORT(R_NO_MEMORY); obj->ssl_ctx=(ssl_decode_ctx *)ctx; @@ -314,7 +314,7 @@ static int create_r_queue(qp) r_queue *q=0; int _status; - if(!(q=(r_queue *)calloc(sizeof(r_queue),1))) + if(!(q=(r_queue *)calloc(1,sizeof(r_queue)))) ABORT(R_NO_MEMORY); if(!(q->data=(UCHAR *)malloc(SSL_HEADER_SIZE))) diff --git a/ssl/ssl_rec.c b/ssl/ssl_rec.c index ffa2e73..85b46a2 100644 --- a/ssl/ssl_rec.c +++ b/ssl/ssl_rec.c @@ -119,7 +119,7 @@ int ssl_create_rec_decoder(dp,cs,mk,sk,iv) ciph=EVP_enc_null(); } - if(!(dec=(ssl_rec_decoder *)calloc(sizeof(ssl_rec_decoder),1))) + if(!(dec=(ssl_rec_decoder *)calloc(1,sizeof(ssl_rec_decoder)))) ABORT(R_NO_MEMORY); dec->cs=cs; diff --git a/ssl/ssldecode.c b/ssl/ssldecode.c index e373396..c999309 100644 --- a/ssl/ssldecode.c +++ b/ssl/ssldecode.c @@ -185,7 +185,7 @@ int ssl_decoder_create(dp,ctx) ssl_decoder *d=0; #ifdef OPENSSL - if(!(d=(ssl_decoder *)calloc(sizeof(ssl_decoder),1))) + if(!(d=(ssl_decoder *)calloc(1,sizeof(ssl_decoder)))) ABORT(R_NO_MEMORY); d->ctx=ctx; From e49030e3b44e6f54b86064b58dbedcae1d6dc199 Mon Sep 17 00:00:00 2001 From: William Robinet Date: Mon, 18 May 2015 16:07:18 +0200 Subject: [PATCH 7/7] Include string.h (remove warnings about memcpy) --- common/include/r_includes.h | 1 + 1 file changed, 1 insertion(+) diff --git a/common/include/r_includes.h b/common/include/r_includes.h index cc9d6b5..de9b76c 100644 --- a/common/include/r_includes.h +++ b/common/include/r_includes.h @@ -56,6 +56,7 @@ #endif #include +#include #endif