mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-02-06 06:55:07 +00:00
Fix possible non null-terminated string issue in socket sample (#1612)
This commit is contained in:
parent
7cc7b56f88
commit
ace05b182d
|
@ -53,7 +53,7 @@ main(int argc, char *argv[])
|
|||
struct ip_mreq ipv4_group;
|
||||
int sd;
|
||||
int datalen;
|
||||
char databuf[1024];
|
||||
char databuf[1024] = { 0 };
|
||||
char multicast_addr_buffer[16];
|
||||
struct sockaddr_storage local_address = { 0 };
|
||||
int addr_type = -1;
|
||||
|
@ -116,7 +116,7 @@ main(int argc, char *argv[])
|
|||
|
||||
printf("Joined multicast group. Waiting for datagram...\n");
|
||||
|
||||
datalen = sizeof(databuf);
|
||||
datalen = sizeof(databuf) - 1;
|
||||
read_result = read(sd, databuf, datalen);
|
||||
|
||||
if (read_result < 0) {
|
||||
|
@ -132,4 +132,4 @@ main(int argc, char *argv[])
|
|||
fail:
|
||||
close(sd);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user