mirror of
				https://git.code.sf.net/p/linux-ima/ima-evm-utils
				synced 2025-11-04 06:40:49 +01:00 
			
		
		
		
	ima-evm-utils: Fix null dereference from file2bin to memcpy
file2bin() may return NULL, which is set to tmp, which is passed to memcpy. Add explicit check for it. Fixes: CID 229904. Signed-off-by: Vitaly Chikunov <vt@altlinux.org> Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
This commit is contained in:
		
				
					committed by
					
						
						Mimi Zohar
					
				
			
			
				
	
			
			
			
						parent
						
							164c51ff2b
						
					
				
				
					commit
					d47951c6e1
				
			
							
								
								
									
										10
									
								
								src/evmctl.c
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								src/evmctl.c
									
									
									
									
									
								
							@@ -821,7 +821,15 @@ static int verify_ima(const char *file)
 | 
			
		||||
	if (sigfile) {
 | 
			
		||||
		void *tmp = file2bin(file, "sig", &len);
 | 
			
		||||
 | 
			
		||||
		assert(len <= sizeof(sig));
 | 
			
		||||
		if (!tmp) {
 | 
			
		||||
			log_err("Failed reading: %s\n", file);
 | 
			
		||||
			return -1;
 | 
			
		||||
		}
 | 
			
		||||
		if (len > sizeof(sig)) {
 | 
			
		||||
			log_err("Signature file is too big: %s\n", file);
 | 
			
		||||
			free(tmp);
 | 
			
		||||
			return -1;
 | 
			
		||||
		}
 | 
			
		||||
		memcpy(sig, tmp, len);
 | 
			
		||||
		free(tmp);
 | 
			
		||||
	} else {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user