diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-02-12 20:49:33 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-02-12 20:49:33 +0000 |
commit | 66bebc21e2a2aead4393f98003986299f85ff425 (patch) | |
tree | 43dfa5722d3a6d89724eb8361d98b874b1eb6811 | |
parent | 05d03bfcd69957c34af36fa65e44e602c489e46f (diff) | |
download | rspamd-66bebc21e2a2aead4393f98003986299f85ff425.tar.gz rspamd-66bebc21e2a2aead4393f98003986299f85ff425.zip |
[Minor] Treat EPERM specially
Issue: #1996
-rw-r--r-- | contrib/libucl/ucl_internal.h | 2 | ||||
-rw-r--r-- | contrib/libucl/ucl_util.c | 21 |
2 files changed, 18 insertions, 5 deletions
diff --git a/contrib/libucl/ucl_internal.h b/contrib/libucl/ucl_internal.h index 44a8fe70e..11b71de70 100644 --- a/contrib/libucl/ucl_internal.h +++ b/contrib/libucl/ucl_internal.h @@ -321,7 +321,7 @@ ucl_create_err (UT_string **err, const char *fmt, ...) } #ifdef UCL_FATAL_ERRORS - assert (0); + abort (); #endif } diff --git a/contrib/libucl/ucl_util.c b/contrib/libucl/ucl_util.c index f0ce5b5e3..85b700a4d 100644 --- a/contrib/libucl/ucl_util.c +++ b/contrib/libucl/ucl_util.c @@ -751,13 +751,20 @@ ucl_fetch_file (const unsigned char *filename, unsigned char **buf, size_t *bufl int fd; struct stat st; - if (stat (filename, &st) == -1 || !S_ISREG (st.st_mode)) { - if (must_exist) { + if (stat (filename, &st) == -1) { + if (must_exist || errno == EPERM) { ucl_create_err (err, "cannot stat file %s: %s", filename, strerror (errno)); } return false; } + if (!S_ISREG (st.st_mode)) { + if (must_exist) { + ucl_create_err (err, "file %s is not a regular file", filename); + } + + return false; + } if (st.st_size == 0) { /* Do not map empty files */ *buf = NULL; @@ -951,9 +958,10 @@ ucl_include_file_single (const unsigned char *data, size_t len, if (params->soft_fail) { return false; } - if (!params->must_exist) { + if (!params->must_exist && errno != EPERM) { return true; } + ucl_create_err (&parser->err, "cannot open file %s: %s", filebuf, strerror (errno)); @@ -976,7 +984,12 @@ ucl_include_file_single (const unsigned char *data, size_t len, return false; } - return (!params->must_exist || false); + if (params->must_exist || parser->err != NULL) { + /* The case of fatal errors */ + return false; + } + + return true; } if (params->check_signature) { |