Skip to content
Snippets Groups Projects
Commit 5cbfaeca authored by Simon McVittie's avatar Simon McVittie
Browse files

resolve-in-sysroot: Don't return real path if not readable


The GLib convention is that "out" parameters are untouched on error,
and PV_RESOLVE_FLAGS_READABLE makes it an error for the file to be
unreadable.

Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
parent 25eaf9a2
No related branches found
No related tags found
1 merge request!138Minor fixes
Pipeline #4609 passed
...@@ -303,9 +303,6 @@ pv_resolve_in_sysroot (int sysroot, ...@@ -303,9 +303,6 @@ pv_resolve_in_sysroot (int sysroot,
} }
} }
if (real_path_out != NULL)
*real_path_out = g_string_free (g_steal_pointer (&current_path), FALSE);
if (flags & PV_RESOLVE_FLAGS_READABLE) if (flags & PV_RESOLVE_FLAGS_READABLE)
{ {
g_autofree char *proc_fd_name = g_strdup_printf ("/proc/self/fd/%d", g_autofree char *proc_fd_name = g_strdup_printf ("/proc/self/fd/%d",
...@@ -316,9 +313,15 @@ pv_resolve_in_sysroot (int sysroot, ...@@ -316,9 +313,15 @@ pv_resolve_in_sysroot (int sysroot,
if (!glnx_openat_rdonly (-1, proc_fd_name, TRUE, &fd, error)) if (!glnx_openat_rdonly (-1, proc_fd_name, TRUE, &fd, error))
return -1; return -1;
if (real_path_out != NULL)
*real_path_out = g_string_free (g_steal_pointer (&current_path), FALSE);
return glnx_steal_fd (&fd); return glnx_steal_fd (&fd);
} }
if (real_path_out != NULL)
*real_path_out = g_string_free (g_steal_pointer (&current_path), FALSE);
/* Taking the address might look like nonsense here, but it's /* Taking the address might look like nonsense here, but it's
* documented to work: g_array_index expands to fds->data[some_offset]. * documented to work: g_array_index expands to fds->data[some_offset].
* We need to steal ownership of the fd back from @fds so it won't be * We need to steal ownership of the fd back from @fds so it won't be
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment