1
0
mirror of https://github.com/coturn/coturn.git synced 2025-10-30 06:20:59 +01:00

Fix resource leaks (#1048)

This commit is contained in:
Gregor Jasny 2022-10-27 23:07:21 +02:00 committed by GitHub
parent ab1292059f
commit d992d0c049
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 1 deletions

View File

@ -125,6 +125,7 @@ static int encode_token(const char* server_name,
size_t base64encoded_etoken_length;
const char *tmp=base64_encode((unsigned char *)(etoken.token), etoken.size, &base64encoded_etoken_length);
STRCPY(base64encoded_etoken,tmp);
free(tmp);
return 0;
}
@ -142,6 +143,7 @@ static int validate_decode_token(const char* server_name,
const size_t base64encoded_etoken_length=strlen(base64encoded_etoken);
const unsigned char *tmp = base64_decode(base64encoded_etoken,base64encoded_etoken_length,&etoken.size);
memcpy(etoken.token,tmp,etoken.size);
free(tmp);
if (decode_oauth_token((const uint8_t *) server_name, &etoken, &key, dot) < 0) {
fprintf(stderr, "%s: cannot decode oauth token\n",
@ -160,6 +162,7 @@ static void print_token_body(oauth_token* dot) {
const char *base64encoded_nonce = base64_encode((unsigned char *)dot->enc_block.nonce, dot->enc_block.nonce_length,&base64encoded_nonce_length);
printf(" nonce: %s\n", base64encoded_nonce);
printf(" nonce length: %d\n", (int) dot->enc_block.nonce_length);
free(base64encoded_nonce);
printf("Token encrpyted body:\n");
printf("{\n");
printf(" mac key: %s\n", (char*) dot->enc_block.mac_key);

View File

@ -77,6 +77,7 @@ static int udp_create_server_socket(server_type* server,
udp_fd = socket(server_addr->ss.sa_family, RELAY_DGRAM_SOCKET_TYPE, RELAY_DGRAM_SOCKET_PROTOCOL);
if (udp_fd < 0) {
perror("socket");
free(server_addr);
return -1;
}

View File

@ -71,6 +71,7 @@ static void MyconninfoFree(Myconninfo *co) {
if(co->capath) free(co->capath);
if(co->cipher) free(co->cipher);
memset(co,0,sizeof(Myconninfo));
free(co);
}
}

View File

@ -255,10 +255,12 @@ static int clnet_connect(uint16_t clnet_remote_port, const char *remote_address,
if(remote_addr.ss.sa_family == AF_INET6) {
if (make_ioa_addr((const uint8_t*) "::1", 0, &local_addr) < 0) {
socket_closesocket(clnet_fd);
return -1;
}
} else {
if (make_ioa_addr((const uint8_t*) "127.0.0.1", 0, &local_addr) < 0) {
socket_closesocket(clnet_fd);
return -1;
}
}
@ -268,8 +270,10 @@ static int clnet_connect(uint16_t clnet_remote_port, const char *remote_address,
} else if (strlen(local_address) > 0) {
if (make_ioa_addr((const uint8_t*) local_address, 0,
&local_addr) < 0)
&local_addr) < 0) {
socket_closesocket(clnet_fd);
return -1;
}
addr_bind(clnet_fd, &local_addr,0,1,get_socket_type());
}