From b02c40bca4d64da65b6f78d6ff9ca2d28df6f6b8 Mon Sep 17 00:00:00 2001 From: Tollef Fog Heen Date: Sun, 15 May 2011 14:08:21 +0200 Subject: [PATCH] Only treat real files (or symlinks to real files) as .pc files Ignore any dangling symlinks. Thanks to Ciaran Anscomb for patch inspiration. Fixes Freedesktop #23922 --- pkg.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/pkg.c b/pkg.c index 6834dfa..df9e2e1 100644 --- a/pkg.c +++ b/pkg.c @@ -203,13 +203,17 @@ scan_dir (const char *dirname) filename[dirnamelen] = G_DIR_SEPARATOR; strcpy (filename + dirnamelen + 1, dent->d_name); - g_hash_table_insert (locations, pkgname, filename); - g_hash_table_insert (path_positions, pkgname, - GINT_TO_POINTER (scanned_dir_count)); - - debug_spew ("Will find package '%s' in file '%s'\n", - pkgname, filename); - } + if (g_file_test(filename, G_FILE_TEST_IS_REGULAR) == TRUE) { + g_hash_table_insert (locations, pkgname, filename); + g_hash_table_insert (path_positions, pkgname, + GINT_TO_POINTER (scanned_dir_count)); + debug_spew ("Will find package '%s' in file '%s'\n", + pkgname, filename); + } else { + debug_spew ("Ignoring '%s' while looking for '%s'; not a " + "regular file.\n", pkgname, filename); + } + } } else {