Merge pull request #5 from wllm-rbnt/master

More code cleaning
This commit is contained in:
Alexandre Dulaunoy 2015-05-18 21:54:31 +02:00
commit d4ce6d1ff7
13 changed files with 30 additions and 14 deletions

View file

@ -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));

View file

@ -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);
}

View file

@ -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,

View file

@ -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;

View file

@ -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);

View file

@ -56,6 +56,7 @@
#endif
#include <stdio.h>
#include <string.h>
#endif

View file

@ -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);
}

View file

@ -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;

View file

@ -107,7 +107,4 @@ int r_bitfield_isset(set,bit)
return(0);
return(set->data[word]&(1<<bbit));
_status=0;
return(_status);
}

View file

@ -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++;

View file

@ -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)))

View file

@ -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;

View file

@ -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;