mirror of
				https://git.proxmox.com/git/efi-boot-shim
				synced 2025-11-04 02:26:53 +00:00 
			
		
		
		
	SBAT: parse a copy of the table that's got a NUL at the end
Right now we allocate the PE file's contents in RW memory, but hopefully that won't always be the case. Our SBAT parsing, however, very much expects to be able to edit it. We also don't actually know that shim's .sbat section is loaded r/w, so we can't necessarily write there. This patch copies the SBAT data to its own buffer, plus one NUL byte at the end, so we can always be sure that will work. Signed-off-by: Peter Jones <pjones@redhat.com>
This commit is contained in:
		
							parent
							
								
									ee8f7ed332
								
							
						
					
					
						commit
						6b8ef61a1a
					
				
							
								
								
									
										14
									
								
								pe.c
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								pe.c
									
									
									
									
									
								
							@ -1045,7 +1045,19 @@ handle_image (void *data, unsigned int datasize,
 | 
			
		||||
		struct sbat_entry *entry = NULL;
 | 
			
		||||
 | 
			
		||||
		if (SBATBase && SBATSize) {
 | 
			
		||||
			res = parse_sbat(SBATBase, SBATSize, buffer, &sbat);
 | 
			
		||||
			char *sbat_data;
 | 
			
		||||
			size_t sbat_size;
 | 
			
		||||
 | 
			
		||||
			sbat_size = SBATSize + 1;
 | 
			
		||||
			sbat_data = AllocatePool(sbat_size);
 | 
			
		||||
			if (!sbat_data) {
 | 
			
		||||
				console_print(L"Failed to allocate SBAT buffer\n");
 | 
			
		||||
				return EFI_OUT_OF_RESOURCES;
 | 
			
		||||
			}
 | 
			
		||||
			CopyMem(sbat_data, SBATBase, SBATSize);
 | 
			
		||||
			sbat_data[SBATSize] = '\0';
 | 
			
		||||
 | 
			
		||||
			res = parse_sbat(sbat_data, sbat_size, buffer, &sbat);
 | 
			
		||||
			if (res < 0) {
 | 
			
		||||
				console_print(L"SBAT data not correct: %r\n", res);
 | 
			
		||||
				return EFI_UNSUPPORTED;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user