diff --git a/cmdline/handle.c b/cmdline/handle.c index 042bae4f..11522209 100644 --- a/cmdline/handle.c +++ b/cmdline/handle.c @@ -137,6 +137,15 @@ int handle_open_create(struct snapraid_handle* handle, struct snapraid_file* fil /* LCOV_EXCL_STOP */ } + if (!S_ISREG(handle->st.st_mode)) { + /* LCOV_EXCL_START */ + errno = ESOFT; + log_fatal(errno, "Error accessing file '%s' for not regular file.\n", handle->path); + handle_close(handle); + return -1; + /* LCOV_EXCL_STOP */ + } + ret = advise_open(&handle->advise, handle->f); if (ret != 0) { /* LCOV_EXCL_START */ @@ -323,6 +332,15 @@ int handle_open(struct snapraid_handle* handle, struct snapraid_file* file, int /* LCOV_EXCL_STOP */ } + if (!S_ISREG(handle->st.st_mode)) { + /* LCOV_EXCL_START */ + errno = ESOFT; + log_error(errno, "Error accessing file '%s' for not regular file.\n", handle->path); + handle_close(handle); + return -1; + /* LCOV_EXCL_STOP */ + } + ret = advise_open(&handle->advise, handle->f); if (ret != 0) { /* LCOV_EXCL_START */ diff --git a/cmdline/parity.c b/cmdline/parity.c index d5a90d45..5ea3b735 100644 --- a/cmdline/parity.c +++ b/cmdline/parity.c @@ -212,6 +212,14 @@ int parity_create(struct snapraid_parity_handle* handle, const struct snapraid_p /* LCOV_EXCL_STOP */ } + if (!S_ISREG(split->st.st_mode)) { + /* LCOV_EXCL_START */ + errno = ESOFT; + log_fatal(errno, "Error accessing parity file '%s' for not regular file.\n", split->path); + goto bail; + /* LCOV_EXCL_STOP */ + } + /** * If the parity size is not yet set, set it now. * This happens when adding a new parity level or split that has @@ -868,6 +876,14 @@ int parity_open(struct snapraid_parity_handle* handle, const struct snapraid_par /* LCOV_EXCL_STOP */ } + if (!S_ISREG(split->st.st_mode)) { + /* LCOV_EXCL_START */ + errno = ESOFT; + log_fatal(errno, "Error accessing parity file '%s' for not regular file.\n", split->path); + goto bail; + /* LCOV_EXCL_STOP */ + } + /** * If the parity size is not yet set, set it now. * This happens when adding a new parity level or split that has