Fixed crash when 0 length packet was send to tunnel

Now UDP packets with 0 length are discarded without answer to sender.
Minor
This commit is contained in:
Angel Garcia 2019-05-23 04:13:07 +02:00
parent e0987aa83a
commit 0bbf7ad5e4
3 changed files with 12 additions and 1 deletions

View File

@ -139,7 +139,9 @@ int main(int argc, char** argv) {
radio.startListening();
#endif
//clean buffer
//buffer[0]='\0';
//memset(buffer, 0, sizeof(buffer));
}while(loop_on);

View File

@ -154,6 +154,10 @@ int main(int argc, char** argv){
inet_ntoa(cliaddr.sin_addr), // addrress
ntohs(cliaddr.sin_port) // port
);
if ( n ==0 ) {
printf("empty msg, discarded\n");
continue;
}
printf("MSG: \'%s\'\n", buffer);
@ -203,6 +207,10 @@ int main(int argc, char** argv){
(const struct sockaddr *) &cliaddr, cliaddr_len
);
//clean buffer
//buffer[0]='\0';
//memset(buffer, 0, sizeof(buffer));
}while(loop_on);
// Power down the antenna

View File

@ -63,5 +63,6 @@ do{
buffer[n] = '\0';
printf("ANS: \'%s\'\n", buffer);
//buffer[0]='\0';
}while(loop_on);
}