Commit 1c956bef authored by Titouan Soulard's avatar Titouan Soulard

libcapulet: avoid memory leak

parent 6975631b
......@@ -156,7 +156,9 @@ bool capulet_net_udp_query_mr(int server_socket, struct addrinfo *server_infos,
int result;
uint8_t receive_buffer[buffer_size];
memcpy((void *) mr_query_packet.name, (void *) name, 16);
// Ensure string will always be NUL-terminated
strncpy((void *) mr_query_packet.name, (void *) name, 15);
mr_query_packet.name[15] = '\0';
result = sendto(server_socket, (void *) &mr_query_packet, sizeof(struct CapuletNetUdpMrQueryPacket), 0, server_infos->ai_addr, server_infos->ai_addrlen);
if(result == -1) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment