From 820dac7c723ec6fce8559fa26cfe18adf1e0b304 Mon Sep 17 00:00:00 2001 From: Brad Whittington Date: Sat, 5 Mar 2022 19:05:35 +0200 Subject: [PATCH] Check that the path passed in to copy_file_secure_dest is actually a file This is a copy-pasta proposed fix for the issue I logged in #90 --- lib/file/file.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/file/file.c b/lib/file/file.c index 60280057..e74d9b53 100644 --- a/lib/file/file.c +++ b/lib/file/file.c @@ -45,6 +45,14 @@ int copy_file_secure_dest(void *ctx, const char *source_file, ssize_t r; size_t l1; + struct stat statbuf; + stat(source_file, &statbuf); + if (!S_ISREG(statbuf.st_mode)) { + pb_log("%s: unable to stat source file '%s': %m\n", + __func__, source_file); + return -1; + } + source_handle = fopen(source_file, "r"); if (!source_handle) { pb_log("%s: unable to open source file '%s': %m\n",