journal-file: refuse opening non-regular journal files
Let's check the file node type when we open/stat journal files: refuse anything that is not a regular file...
This commit is contained in:
@@ -651,6 +651,12 @@ static int journal_file_fstat(JournalFile *f) {
|
||||
|
||||
f->last_stat_usec = now(CLOCK_MONOTONIC);
|
||||
|
||||
/* Refuse dealing with with files that aren't regular */
|
||||
if (S_ISDIR(f->last_stat.st_mode))
|
||||
return -EISDIR;
|
||||
if (!S_ISREG(f->last_stat.st_mode))
|
||||
return -EBADFD;
|
||||
|
||||
/* Refuse appending to files that are already deleted */
|
||||
if (f->last_stat.st_nlink <= 0)
|
||||
return -EIDRM;
|
||||
|
||||
@@ -2016,6 +2016,10 @@ _public_ int sd_journal_open_files_fd(sd_journal **ret, int fds[], unsigned n_fd
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
r = -EISDIR;
|
||||
goto fail;
|
||||
}
|
||||
if (!S_ISREG(st.st_mode)) {
|
||||
r = -EBADFD;
|
||||
goto fail;
|
||||
|
||||
Reference in New Issue
Block a user