lib/download.c: fix digestlen assert and add if condition to avoid misuse
This commit is contained in:
		
				
					committed by
					
						
						Juan RP
					
				
			
			
				
	
			
			
			
						parent
						
							2ef79bcc09
						
					
				
				
					commit
					d99aae586a
				
			@@ -111,8 +111,12 @@ xbps_fetch_file_dest_sha256(struct xbps_handle *xhp, const char *uri, const char
 | 
			
		||||
	assert(xhp);
 | 
			
		||||
	assert(uri);
 | 
			
		||||
 | 
			
		||||
	if (digest) {
 | 
			
		||||
		assert(digestlen != XBPS_SHA256_DIGEST_SIZE);
 | 
			
		||||
	if (digest != NULL) {
 | 
			
		||||
		assert(digestlen >= XBPS_SHA256_DIGEST_SIZE);
 | 
			
		||||
		if (digestlen < XBPS_SHA256_DIGEST_SIZE) {
 | 
			
		||||
			errno = ENOBUFS;
 | 
			
		||||
			return -1;
 | 
			
		||||
		}
 | 
			
		||||
		SHA256_Init(&sha256);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user