mirror of
				https://github.com/coturn/coturn.git
				synced 2025-10-31 06:51:30 +01:00 
			
		
		
		
	Fix resource leaks (#1048)
This commit is contained in:
		
							parent
							
								
									ab1292059f
								
							
						
					
					
						commit
						d992d0c049
					
				| @ -125,6 +125,7 @@ static int encode_token(const char* server_name, | |||||||
|         size_t base64encoded_etoken_length; |         size_t base64encoded_etoken_length; | ||||||
|         const char *tmp=base64_encode((unsigned char *)(etoken.token), etoken.size, &base64encoded_etoken_length); |         const char *tmp=base64_encode((unsigned char *)(etoken.token), etoken.size, &base64encoded_etoken_length); | ||||||
|         STRCPY(base64encoded_etoken,tmp); |         STRCPY(base64encoded_etoken,tmp); | ||||||
|  |         free(tmp); | ||||||
| 
 | 
 | ||||||
|         return 0; |         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 size_t base64encoded_etoken_length=strlen(base64encoded_etoken); | ||||||
|         const unsigned char *tmp = base64_decode(base64encoded_etoken,base64encoded_etoken_length,&etoken.size); |         const unsigned char *tmp = base64_decode(base64encoded_etoken,base64encoded_etoken_length,&etoken.size); | ||||||
|         memcpy(etoken.token,tmp,etoken.size); |         memcpy(etoken.token,tmp,etoken.size); | ||||||
|  |         free(tmp); | ||||||
|                          |                          | ||||||
|         if (decode_oauth_token((const uint8_t *) server_name, &etoken, &key, dot) < 0) { |         if (decode_oauth_token((const uint8_t *) server_name, &etoken, &key, dot) < 0) { | ||||||
|                 fprintf(stderr, "%s: cannot decode oauth token\n", |                 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);  |         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: %s\n", base64encoded_nonce); | ||||||
|         printf("    nonce length: %d\n", (int) dot->enc_block.nonce_length); |         printf("    nonce length: %d\n", (int) dot->enc_block.nonce_length); | ||||||
|  |         free(base64encoded_nonce); | ||||||
|         printf("Token encrpyted body:\n"); |         printf("Token encrpyted body:\n"); | ||||||
|         printf("{\n"); |         printf("{\n"); | ||||||
|         printf("    mac key: %s\n", (char*) dot->enc_block.mac_key); |         printf("    mac key: %s\n", (char*) dot->enc_block.mac_key); | ||||||
|  | |||||||
| @ -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); |   udp_fd = socket(server_addr->ss.sa_family, RELAY_DGRAM_SOCKET_TYPE, RELAY_DGRAM_SOCKET_PROTOCOL); | ||||||
|   if (udp_fd < 0) { |   if (udp_fd < 0) { | ||||||
|     perror("socket"); |     perror("socket"); | ||||||
|  |     free(server_addr); | ||||||
|     return -1; |     return -1; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -71,6 +71,7 @@ static void MyconninfoFree(Myconninfo *co) { | |||||||
| 		if(co->capath) free(co->capath); | 		if(co->capath) free(co->capath); | ||||||
| 		if(co->cipher) free(co->cipher); | 		if(co->cipher) free(co->cipher); | ||||||
| 		memset(co,0,sizeof(Myconninfo)); | 		memset(co,0,sizeof(Myconninfo)); | ||||||
|  | 		free(co); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -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(remote_addr.ss.sa_family == AF_INET6) { | ||||||
| 			if (make_ioa_addr((const uint8_t*) "::1", 0, &local_addr) < 0) { | 			if (make_ioa_addr((const uint8_t*) "::1", 0, &local_addr) < 0) { | ||||||
|  | 			    socket_closesocket(clnet_fd); | ||||||
| 			    return -1; | 			    return -1; | ||||||
| 			} | 			} | ||||||
| 		} else { | 		} else { | ||||||
| 			if (make_ioa_addr((const uint8_t*) "127.0.0.1", 0, &local_addr) < 0) { | 			if (make_ioa_addr((const uint8_t*) "127.0.0.1", 0, &local_addr) < 0) { | ||||||
|  | 			    socket_closesocket(clnet_fd); | ||||||
| 			    return -1; | 			    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) { | 	} else if (strlen(local_address) > 0) { | ||||||
| 
 | 
 | ||||||
| 		if (make_ioa_addr((const uint8_t*) 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; | 			return -1; | ||||||
|  | 		} | ||||||
| 
 | 
 | ||||||
| 		addr_bind(clnet_fd, &local_addr,0,1,get_socket_type()); | 		addr_bind(clnet_fd, &local_addr,0,1,get_socket_type()); | ||||||
| 	} | 	} | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user