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

ld_libs_load_cache: Don't use prefix.path as scratch space


Previously, we'd write /etc/ld.so.cache into prefix.path[prefix.len:]:

    /host/etc/ld.so.cache\0\0...
    |<->||<------------>|
     len   temporarily used

and delete it again later with sanitise_ldlibs(). But that seems
unnecessarily confusing: the contents of prefix.path when interpreted
as an ordinary \0-terminated C string are sometimes the prefix, but
sometimes edited in-place to be the name of a file within the prefix.

Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
parent 0f1e6039
No related branches found
No related tags found
1 merge request!311Build capsule-capture-libs from a bundled copy of libcapsule
......@@ -1115,19 +1115,21 @@ stat_caller (void)
int
ld_libs_load_cache (ld_libs *libs, const char *path, int *code, char **message)
{
char prefixed[PATH_MAX] = { '\0' };
int rv;
if( libs->prefix.len == 0 )
{
safe_strncpy( libs->prefix.path, path, sizeof(libs->prefix.path) );
safe_strncpy( prefixed, path, sizeof(prefixed) );
}
else
{
safe_strncpy( libs->prefix.path + libs->prefix.len,
safe_strncpy( prefixed, libs->prefix.path, sizeof(prefixed) );
safe_strncpy( prefixed + libs->prefix.len,
path, PATH_MAX - libs->prefix.len );
}
rv = ld_cache_open( &libs->ldcache, libs->prefix.path, code, message );
rv = ld_cache_open( &libs->ldcache, prefixed, code, message );
return rv;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment