commit 9af27fcb9c07d0118dd1986a23a9d04b3c5acc71
parent ae5935f8ea97c2fecbc95149b96377f71d8cb802
Author: Colin Leroy <colin@colino.net>
Date: Thu, 8 Oct 2015 18:59:49 +0200
Fix TOCTOU (time-to-check, time-to-use) race
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/plugins/archive/libarchive_archive.c b/src/plugins/archive/libarchive_archive.c
@@ -551,11 +551,11 @@ const gchar* archive_create(const char* archive_name, GSList* files,
g_free(msg);
#endif
entry = archive_entry_new();
- lstat(filename, &st);
if ((fd = open(filename, O_RDONLY)) == -1) {
perror("open file");
}
else {
+ lstat(filename, &st);
archive_entry_copy_stat(entry, &st);
archive_entry_set_pathname(entry, filename);
if (S_ISLNK(st.st_mode)) {