@@ -1169,7 +1169,7 @@ static char* getCacheLocation(char *env_var)
11691169 return strdup (last_slash );
11701170}
11711171
1172- static int checkLinkForLeak (const char * path , const char * spindle_loc )
1172+ static int checkLinkForLeak (const char * path , const char * cachepath )
11731173{
11741174 char link_target [4096 ];
11751175 int result , error ;
@@ -1182,34 +1182,34 @@ static int checkLinkForLeak(const char *path, const char *spindle_loc)
11821182 return -1 ;
11831183 }
11841184
1185- if (strstr (link_target , spindle_loc )) {
1186- err_printf ("Link at '%s' has path '%s', which leaks spindle path with '%s'\n" , path , link_target , spindle_loc );
1185+ if (strstr (link_target , cachepath )) {
1186+ err_printf ("Link at '%s' has path '%s', which leaks spindle path with '%s'\n" , path , link_target , cachepath );
11871187 return -1 ;
11881188 }
11891189
11901190 return 0 ;
11911191}
11921192
11931193
1194- static int checkPathForLeak (const char * what , const char * path , const char * spindle_loc )
1194+ static int checkPathForLeak (const char * what , const char * path , const char * cachepath )
11951195{
1196- if (strstr (path , spindle_loc )) {
1197- err_printf ("%s: Path '%s' leaks spindle path with '%s'\n" , what , path , spindle_loc );
1196+ if (strstr (path , cachepath )) {
1197+ err_printf ("%s: Path '%s' leaks spindle path with '%s'\n" , what , path , cachepath );
11981198 return -1 ;
11991199 }
12001200 return 0 ;
12011201}
12021202
12031203static int leak_check_cb (struct dl_phdr_info * p , size_t psize , void * opaque )
12041204{
1205- char * spindle_loc = (char * ) opaque ;
1205+ char * cachepath = (char * ) opaque ;
12061206 if (!p -> dlpi_name || p -> dlpi_name [0 ] == '\0' )
12071207 return 0 ;
1208- checkPathForLeak ("dl_iterate_phdr" , p -> dlpi_name , spindle_loc );
1208+ checkPathForLeak ("dl_iterate_phdr" , p -> dlpi_name , cachepath );
12091209 return 0 ;
12101210}
12111211
1212- static int check_proc_maps (char * path , char * spindle_loc )
1212+ static int check_proc_maps (char * path , char * cachepath )
12131213{
12141214 int fd , error , result ;
12151215 struct stat statbuf ;
@@ -1248,8 +1248,8 @@ static int check_proc_maps(char *path, char *spindle_loc)
12481248 maps [filesize ] = '\0' ;
12491249 close (fd );
12501250
1251- if (strstr (maps , spindle_loc )) {
1252- err_printf ("Found leaked spindle path '%s' in maps '%s'\n" , spindle_loc , path );
1251+ if (strstr (maps , cachepath )) {
1252+ err_printf ("Found leaked spindle path '%s' in maps '%s'\n" , cachepath , path );
12531253 return -1 ;
12541254 }
12551255
@@ -1259,17 +1259,15 @@ static int check_proc_maps(char *path, char *spindle_loc)
12591259
12601260void check_for_path_leaks ()
12611261{
1262- char * spindle_loc = NULL ;
1262+ char * cachepath = NULL ;
12631263 DIR * proc_fds = NULL ;
12641264 struct dirent * d ;
12651265 char path [4096 ];
12661266 struct link_map * lm ;
12671267 char * dlerr_msg = NULL ;
12681268
1269- spindle_loc = getCacheLocation ("LDCS_LOCATION" );
1270- if (!spindle_loc )
1271- spindle_loc = getCacheLocation ("LDCS_ORIG_LOCATION" );
1272- if (!spindle_loc ) {
1269+ cachepath = getCacheLocation ("LDCS_CHOSEN_PARSED_CACHEPATH" );
1270+ if (!cachepath ) {
12731271 err_printf ("Failed to calculate cache location" );
12741272 goto done ;
12751273 }
@@ -1287,32 +1285,32 @@ void check_for_path_leaks()
12871285 continue ;
12881286 strncpy (path , "/proc/self/fd/" , sizeof (path ));
12891287 strncat (path , d -> d_name , sizeof (path )- 1 );
1290- checkLinkForLeak (path , spindle_loc );
1288+ checkLinkForLeak (path , cachepath );
12911289 }
1292- checkLinkForLeak ("/proc/self/exe" , spindle_loc );
1290+ checkLinkForLeak ("/proc/self/exe" , cachepath );
12931291
12941292 /**
12951293 * Check link_maps for leaked spindle paths
12961294 **/
12971295 for (lm = _r_debug .r_map ; lm != NULL ; lm = lm -> l_next ) {
12981296 if (!lm -> l_name || lm -> l_name [0 ] == '\0' )
12991297 continue ;
1300- checkPathForLeak ("link_map" , lm -> l_name , spindle_loc );
1298+ checkPathForLeak ("link_map" , lm -> l_name , cachepath );
13011299 }
13021300
13031301 /**
13041302 * Check libraries in dl_iterate_phdr for leaked paths
13051303 **/
1306- dl_iterate_phdr (leak_check_cb , spindle_loc );
1304+ dl_iterate_phdr (leak_check_cb , cachepath );
13071305
13081306 /**
13091307 * Check /proc/pid/maps under various aliases for leaked names
13101308 **/
1311- check_proc_maps ("/proc/self/maps" , spindle_loc );
1309+ check_proc_maps ("/proc/self/maps" , cachepath );
13121310 snprintf (path , sizeof (path ), "/proc/self/task/%d/maps" , getpid ());
1313- check_proc_maps (path , spindle_loc );
1311+ check_proc_maps (path , cachepath );
13141312 snprintf (path , sizeof (path ), "/proc/%d/maps" , getpid ());
1315- check_proc_maps (path , spindle_loc );
1313+ check_proc_maps (path , cachepath );
13161314
13171315 /**
13181316 * Check that dlerror doesn't leak the /__not_exists/ prefix
@@ -1324,8 +1322,8 @@ void check_for_path_leaks()
13241322 }
13251323
13261324 done :
1327- if (spindle_loc )
1328- free (spindle_loc );
1325+ if (cachepath )
1326+ free (cachepath );
13291327 if (proc_fds )
13301328 closedir (proc_fds );
13311329}
0 commit comments