efi: check *path non-null before grub_strrchr
The EFI version of grub_machine_get_bootlocation crops the boot image name back to the last / in order to get a directory path. However, it does not check that *name is actually set before calling grub_strrchr to do this, and neither does grub_strrchr before dereferencing a NULL pointer. Parent function, grub_set_prefix_and_root, does check the pointer before using.
This commit is contained in:
		
							parent
							
								
									72ec399ad8
								
							
						
					
					
						commit
						004a2b1efd
					
				
					 2 changed files with 12 additions and 4 deletions
				
			
		|  | @ -63,10 +63,13 @@ grub_machine_get_bootlocation (char **device, char **path) | |||
|   if (!*device && grub_efi_net_config) | ||||
|     grub_efi_net_config (image->device_handle, device, path); | ||||
| 
 | ||||
|   /* Get the directory.  */ | ||||
|   p = grub_strrchr (*path, '/'); | ||||
|   if (p) | ||||
|     *p = '\0'; | ||||
|   if (*path) | ||||
|     { | ||||
|       /* Get the directory.  */ | ||||
|       p = grub_strrchr (*path, '/'); | ||||
|       if (p) | ||||
|         *p = '\0'; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue