lib: uefi: Don't call access(NULL) if no UEFI debug file exists.

Bug found by valgrind on aarch64:

==21350== Syscall param faccessat(pathname) points to unaddressable byte(s)
==21350==    at 0x4F05274: access (access.c:29)
==21350==    by 0x4954DC3: guestfs_int_get_uefi (appliance-uefi.c:90)
==21350==    by 0x49752D7: launch_libvirt (launch-libvirt.c:413)
==21350==    by 0x496FD83: guestfs_impl_launch (launch.c:98)
==21350==    by 0x4902003: guestfs_launch (actions-3.c:145)
[...]
==21350==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
This commit is contained in:
Richard W.M. Jones
2017-01-18 12:19:01 +00:00
parent d45986d21b
commit faff6f23ff

View File

@@ -87,7 +87,7 @@ guestfs_int_get_uefi (guestfs_h *g, char **code, char **vars, int *flags)
/* If debugging is enabled and we can find the code file with
* debugging enabled, use that instead.
*/
if (g->verbose && access (code_debug_file, R_OK) == 0)
if (g->verbose && code_debug_file && access (code_debug_file, R_OK) == 0)
codefile = code_debug_file;
/* Caller frees. */