Skip to content

Commit

Permalink
Check that the path passed in to copy_file_secure_dest is actually a …
Browse files Browse the repository at this point in the history
…file

This is a copy-pasta proposed fix for the issue I logged in open-power#90
  • Loading branch information
BradWhittington authored Mar 5, 2022
1 parent 65b6a5d commit 820dac7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/file/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 820dac7

Please sign in to comment.