Minor bug fixes, mostly todo with uninitialised variables.

This commit is contained in:
Jeremy Lakeman 2011-03-31 00:09:42 +10:30
parent 59a0a4a2a0
commit a2bcb56e1f
5 changed files with 800 additions and 789 deletions

1580
client.c

File diff suppressed because it is too large Load Diff

View File

@ -334,3 +334,4 @@ int readBatmanPeerFile(char *file_path,in_addr_t peers[],int *peer_count,int pee
int getBatmanPeerList(char *socket_path,in_addr_t peers[],int *peer_count,int peer_max);
int hlrDump(unsigned char *hlr,int hofs);
int peerAddress(char *did,char *sid,int flags);
int fixResponses(struct response_set *responses);

View File

@ -136,7 +136,7 @@ int packetMakeHeader(unsigned char *packet,int packet_maxlen,int *packet_len,
for(i=0;i<TRANSID_SIZE;i++) packet[OFS_TRANSIDFIELD+i]=random()&0xff;
/* payload rotation (not yet applied) */
packet[14]=0x00;
packet[OFS_ROTATIONFIELD]=0x00;
*packet_len=HEADERFIELDS_LEN;

View File

@ -93,6 +93,8 @@ int sendToPeers(unsigned char *packet,int packet_len,int method,int peerId,struc
int n=0;
int ret;
struct sockaddr_in peer_addr;
bzero(&peer_addr, sizeof(peer_addr));
peer_addr.sin_family=AF_INET;
peer_addr.sin_port = htons(4110);

View File

@ -102,7 +102,6 @@ int server(char *backing_file,int size,int foregroundMode)
pollfd fds;
int len;
client_port=((struct sockaddr_in*)&recvaddr)->sin_port;
bzero((void *)&recvaddr,sizeof(recvaddr));
fds.fd=sock; fds.events=POLLIN;
@ -110,7 +109,10 @@ int server(char *backing_file,int size,int foregroundMode)
while (poll(&fds,1,1000)<1) sleep(0);
len=recvfrom(sock,buffer,sizeof(buffer),0,&recvaddr,&recvaddrlen);
client_port=((struct sockaddr_in*)&recvaddr)->sin_port;
client_addr=((struct sockaddr_in*)&recvaddr)->sin_addr;
if (debug) fprintf(stderr,"Received packet from %s (len=%d).\n",inet_ntoa(client_addr),len);
if (debug>1) dump("recvaddr",(unsigned char *)&recvaddr,recvaddrlen);
if (debug>3) dump("packet",(unsigned char *)buffer,len);