input_file: refuse to open non-regular files

Don't allow users to open a file which is non-regular (e.g. pipes,
devices).
This commit is contained in:
Max Kellermann 2008-10-29 21:11:28 +01:00
parent 84f7d9c6b3
commit 07bb46de88

View File

@ -50,6 +50,13 @@ input_file_open(struct input_stream *is, const char *filename)
return false;
}
if (!S_ISREG(st.st_mode)) {
g_debug("Not a regular file: %s\n", filename);
is->error = EINVAL;
close(fd);
return false;
}
is->size = st.st_size;
#ifdef POSIX_FADV_SEQUENTIAL