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/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); } 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/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 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); } 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; 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<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 d598b4f..85b46a2 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", @@ -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;