@@ -1142,7 +1142,7 @@ static char* getCacheLocation(char *env_var)
11421142 return strdup (last_slash );
11431143}
11441144
1145- static int checkLinkForLeak (const char * path , const char * spindle_loc )
1145+ static int checkLinkForLeak (const char * path , const char * cachepath )
11461146{
11471147 char link_target [4096 ];
11481148 int result , error ;
@@ -1155,34 +1155,34 @@ static int checkLinkForLeak(const char *path, const char *spindle_loc)
11551155 return -1 ;
11561156 }
11571157
1158- if (strstr (link_target , spindle_loc )) {
1159- err_printf ("Link at '%s' has path '%s', which leaks spindle path with '%s'\n" , path , link_target , spindle_loc );
1158+ if (strstr (link_target , cachepath )) {
1159+ err_printf ("Link at '%s' has path '%s', which leaks spindle path with '%s'\n" , path , link_target , cachepath );
11601160 return -1 ;
11611161 }
11621162
11631163 return 0 ;
11641164}
11651165
11661166
1167- static int checkPathForLeak (const char * what , const char * path , const char * spindle_loc )
1167+ static int checkPathForLeak (const char * what , const char * path , const char * cachepath )
11681168{
1169- if (strstr (path , spindle_loc )) {
1170- err_printf ("%s: Path '%s' leaks spindle path with '%s'\n" , what , path , spindle_loc );
1169+ if (strstr (path , cachepath )) {
1170+ err_printf ("%s: Path '%s' leaks spindle path with '%s'\n" , what , path , cachepath );
11711171 return -1 ;
11721172 }
11731173 return 0 ;
11741174}
11751175
11761176static int leak_check_cb (struct dl_phdr_info * p , size_t psize , void * opaque )
11771177{
1178- char * spindle_loc = (char * ) opaque ;
1178+ char * cachepath = (char * ) opaque ;
11791179 if (!p -> dlpi_name || p -> dlpi_name [0 ] == '\0' )
11801180 return 0 ;
1181- checkPathForLeak ("dl_iterate_phdr" , p -> dlpi_name , spindle_loc );
1181+ checkPathForLeak ("dl_iterate_phdr" , p -> dlpi_name , cachepath );
11821182 return 0 ;
11831183}
11841184
1185- static int check_proc_maps (char * path , char * spindle_loc )
1185+ static int check_proc_maps (char * path , char * cachepath )
11861186{
11871187 int fd , error , result ;
11881188 struct stat statbuf ;
@@ -1221,8 +1221,8 @@ static int check_proc_maps(char *path, char *spindle_loc)
12211221 maps [filesize ] = '\0' ;
12221222 close (fd );
12231223
1224- if (strstr (maps , spindle_loc )) {
1225- err_printf ("Found leaked spindle path '%s' in maps '%s'\n" , spindle_loc , path );
1224+ if (strstr (maps , cachepath )) {
1225+ err_printf ("Found leaked spindle path '%s' in maps '%s'\n" , cachepath , path );
12261226 return -1 ;
12271227 }
12281228
@@ -1232,17 +1232,15 @@ static int check_proc_maps(char *path, char *spindle_loc)
12321232
12331233void check_for_path_leaks ()
12341234{
1235- char * spindle_loc = NULL ;
1235+ char * cachepath = NULL ;
12361236 DIR * proc_fds = NULL ;
12371237 struct dirent * d ;
12381238 char path [4096 ];
12391239 struct link_map * lm ;
12401240 char * dlerr_msg = NULL ;
12411241
1242- spindle_loc = getCacheLocation ("LDCS_LOCATION" );
1243- if (!spindle_loc )
1244- spindle_loc = getCacheLocation ("LDCS_ORIG_LOCATION" );
1245- if (!spindle_loc ) {
1242+ cachepath = getCacheLocation ("LDCS_CHOSEN_PARSED_CACHEPATH" );
1243+ if (!cachepath ) {
12461244 err_printf ("Failed to calculate cache location" );
12471245 goto done ;
12481246 }
@@ -1260,32 +1258,32 @@ void check_for_path_leaks()
12601258 continue ;
12611259 strncpy (path , "/proc/self/fd/" , sizeof (path ));
12621260 strncat (path , d -> d_name , sizeof (path )- 1 );
1263- checkLinkForLeak (path , spindle_loc );
1261+ checkLinkForLeak (path , cachepath );
12641262 }
1265- checkLinkForLeak ("/proc/self/exe" , spindle_loc );
1263+ checkLinkForLeak ("/proc/self/exe" , cachepath );
12661264
12671265 /**
12681266 * Check link_maps for leaked spindle paths
12691267 **/
12701268 for (lm = _r_debug .r_map ; lm != NULL ; lm = lm -> l_next ) {
12711269 if (!lm -> l_name || lm -> l_name [0 ] == '\0' )
12721270 continue ;
1273- checkPathForLeak ("link_map" , lm -> l_name , spindle_loc );
1271+ checkPathForLeak ("link_map" , lm -> l_name , cachepath );
12741272 }
12751273
12761274 /**
12771275 * Check libraries in dl_iterate_phdr for leaked paths
12781276 **/
1279- dl_iterate_phdr (leak_check_cb , spindle_loc );
1277+ dl_iterate_phdr (leak_check_cb , cachepath );
12801278
12811279 /**
12821280 * Check /proc/pid/maps under various aliases for leaked names
12831281 **/
1284- check_proc_maps ("/proc/self/maps" , spindle_loc );
1282+ check_proc_maps ("/proc/self/maps" , cachepath );
12851283 snprintf (path , sizeof (path ), "/proc/self/task/%d/maps" , getpid ());
1286- check_proc_maps (path , spindle_loc );
1284+ check_proc_maps (path , cachepath );
12871285 snprintf (path , sizeof (path ), "/proc/%d/maps" , getpid ());
1288- check_proc_maps (path , spindle_loc );
1286+ check_proc_maps (path , cachepath );
12891287
12901288 /**
12911289 * Check that dlerror doesn't leak the /__not_exists/ prefix
@@ -1297,8 +1295,8 @@ void check_for_path_leaks()
12971295 }
12981296
12991297 done :
1300- if (spindle_loc )
1301- free (spindle_loc );
1298+ if (cachepath )
1299+ free (cachepath );
13021300 if (proc_fds )
13031301 closedir (proc_fds );
13041302}
0 commit comments