[gnome-software: 4/10] gs-utils: Remove redundant g_file_test() check




commit 5eec6b814d684cb7c82d1de4b6d4296db940f398
Author: Philip Withnall <pwithnall endlessos org>
Date:   Sun Feb 20 13:09:26 2022 +0000

    gs-utils: Remove redundant g_file_test() check
    
    If the file doesn’t exist, the `g_file_query_info()` call will fail and
    the return value of the function overall will be the same. The
    `g_file_test()` call is pointless and introduces a slight TOCTTOU race.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>

 lib/gs-utils.c | 3 ---
 1 file changed, 3 deletions(-)
---
diff --git a/lib/gs-utils.c b/lib/gs-utils.c
index 8f8b59e96..1b13e2137 100644
--- a/lib/gs-utils.c
+++ b/lib/gs-utils.c
@@ -1545,9 +1545,6 @@ gs_utils_get_file_etag (const gchar *filename,
 
        g_return_val_if_fail (filename != NULL, NULL);
 
-       if (!g_file_test (filename, G_FILE_TEST_EXISTS))
-               return NULL;
-
        file = g_file_new_for_path (filename);
        info = g_file_query_info (file, METADATA_ETAG_ATTRIBUTE, G_FILE_QUERY_INFO_NONE, cancellable, NULL);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]