mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	modules-raop-sink: improve error handling
This commit is contained in:
		
							parent
							
								
									b4ef9fa333
								
							
						
					
					
						commit
						a3875c38ac
					
				
					 1 changed files with 15 additions and 6 deletions
				
			
		| 
						 | 
					@ -1150,13 +1150,19 @@ done:
 | 
				
			||||||
	RSA *rsa = RSA_new();
 | 
						RSA *rsa = RSA_new();
 | 
				
			||||||
	BIGNUM *n_bn = BN_bin2bn(modulus, msize, NULL);
 | 
						BIGNUM *n_bn = BN_bin2bn(modulus, msize, NULL);
 | 
				
			||||||
	BIGNUM *e_bn = BN_bin2bn(exponent, esize, NULL);
 | 
						BIGNUM *e_bn = BN_bin2bn(exponent, esize, NULL);
 | 
				
			||||||
	RSA_set0_key(rsa, n_bn, e_bn, NULL);
 | 
						if (rsa == NULL || n_bn == NULL || e_bn == NULL)
 | 
				
			||||||
	res = RSA_public_encrypt(len, data, enc, rsa, RSA_PKCS1_OAEP_PADDING);
 | 
							goto error;
 | 
				
			||||||
	if (res <= 0)
 | 
						RSA_set0_key(rsa, n_bn, e_bn NULL);
 | 
				
			||||||
 | 
						n_bn = e_bn = NULL;
 | 
				
			||||||
 | 
						if ((res = RSA_public_encrypt(len, data, enc, rsa, RSA_PKCS1_OAEP_PADDING)) <= 0)
 | 
				
			||||||
		goto error;
 | 
							goto error;
 | 
				
			||||||
done:
 | 
					done:
 | 
				
			||||||
	if (rsa != NULL)
 | 
						if (rsa != NULL)
 | 
				
			||||||
		RSA_free(rsa);
 | 
							RSA_free(rsa);
 | 
				
			||||||
 | 
						if (n_bn != NULL)
 | 
				
			||||||
 | 
							BN_free(n_bn);
 | 
				
			||||||
 | 
						if (e_bn != NULL)
 | 
				
			||||||
 | 
							BN_free(e_bn);
 | 
				
			||||||
	return res;
 | 
						return res;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
error:
 | 
					error:
 | 
				
			||||||
| 
						 | 
					@ -1171,7 +1177,7 @@ static int rtsp_do_announce(struct impl *impl)
 | 
				
			||||||
	uint8_t rsakey[512];
 | 
						uint8_t rsakey[512];
 | 
				
			||||||
	char key[512*2];
 | 
						char key[512*2];
 | 
				
			||||||
	char iv[16*2];
 | 
						char iv[16*2];
 | 
				
			||||||
	int res, frames, i, ip_version;
 | 
						int res, frames, rsa_len, ip_version;
 | 
				
			||||||
	char *sdp;
 | 
						char *sdp;
 | 
				
			||||||
	char local_ip[256];
 | 
						char local_ip[256];
 | 
				
			||||||
	int min_latency;
 | 
						int min_latency;
 | 
				
			||||||
| 
						 | 
					@ -1222,8 +1228,11 @@ static int rtsp_do_announce(struct impl *impl)
 | 
				
			||||||
		    pw_getrandom(impl->iv, sizeof(impl->iv), 0) < 0)
 | 
							    pw_getrandom(impl->iv, sizeof(impl->iv), 0) < 0)
 | 
				
			||||||
			return -errno;
 | 
								return -errno;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		i = rsa_encrypt(impl->key, 16, rsakey);
 | 
							rsa_len = rsa_encrypt(impl->key, 16, rsakey);
 | 
				
			||||||
	        base64_encode(rsakey, i, key, '=');
 | 
							if (rsa_len < 0)
 | 
				
			||||||
 | 
								return -rsa_len;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						        base64_encode(rsakey, rsa_len, key, '=');
 | 
				
			||||||
	        base64_encode(impl->iv, 16, iv, '=');
 | 
						        base64_encode(impl->iv, 16, iv, '=');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		asprintf(&sdp, "v=0\r\n"
 | 
							asprintf(&sdp, "v=0\r\n"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue