@@ -276,24 +276,33 @@ get_user_image_cb(JSContextRef context,
276276 JSObjectRef thisObject ,
277277 JSStringRef propertyName ,
278278 JSValueRef * exception ) {
279- const gchar * image_uri = lightdm_user_get_image (USER );
279+
280+ const gchar * image = lightdm_user_get_image (USER );
280281 gchar * image_path ;
281282 gint result ;
282283
283- image_path = g_filename_from_uri ( image_uri , NULL , NULL );
284- if ( image_path ) {
285- result = g_access ( image_path , R_OK );
286- g_free ( image_path );
287- } else {
288- result = g_access ( image_uri , R_OK );
284+ // Determine if we already checked this path
285+ for ( iter = paths ; iter ; iter = iter -> next ) {
286+ if ( 0 == g_strcmp0 ( image , iter -> data )) {
287+ // We've already checked this path, no need to continue further.
288+ return string_or_null ( context , image );
289+ }
289290 }
290291
291- if (result ) {
292- /* Couldn't access */
293- return JSValueMakeNull (context );
294- } else {
295- return string_or_null (context , image_uri );
292+ image_path = g_strdup (image );
293+ result = g_access (image_path , R_OK );
294+
295+ if (0 == result ) {
296+ // Path is accessible. Add it to our paths list.
297+ paths = g_slist_prepend (paths , image_path );
298+
299+ return string_or_null (context , image );
296300 }
301+
302+ // Path is not accessible.
303+ g_free (image_path );
304+
305+ return JSValueMakeNull (context );
297306}
298307
299308
@@ -1812,7 +1821,7 @@ get_config_option_as_string(const gchar *section, const gchar *key) {
18121821 value = g_key_file_get_string (keyfile , section , key , & err );
18131822
18141823 if (NULL != err ) {
1815- g_error (err -> message );
1824+ g_error ("%s" , err -> message );
18161825 g_error_free (err );
18171826 g_free (value );
18181827 return "" ;
@@ -1835,7 +1844,7 @@ should_block_request(const char *file_path) {
18351844
18361845 if (NULL != canonical_path ) {
18371846 for (iter = paths ; iter ; iter = iter -> next ) {
1838- if (strcmp (canonical_path , iter -> data ) == 0 || g_str_has_prefix (canonical_path , iter -> data )) {
1847+ if (0 == g_strcmp0 (canonical_path , iter -> data ) || g_str_has_prefix (canonical_path , iter -> data )) {
18391848 result = FALSE; /* Allowed */
18401849 break ;
18411850 }
0 commit comments