From: Petr Menšík Date: Mon, 29 Nov 2021 23:04:35 +0000 (+0100) Subject: Improve error message when directory name is given X-Git-Tag: v9.17.22~46^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=929bbe192d92905bcafa8b818fac6e90f0a07c21;p=thirdparty%2Fbind9.git Improve error message when directory name is given Surprising error IO error is returned when directory name is given instead of named.conf file. It can be passed to named-checkconf or include statement. Make a simple change to return Invalid file instead. Still not precise, but much better error message is returned. Fix of rhbz#490837. --- diff --git a/lib/isc/errno2result.c b/lib/isc/errno2result.c index 623ac6dbe9e..0c465952bed 100644 --- a/lib/isc/errno2result.c +++ b/lib/isc/errno2result.c @@ -37,6 +37,8 @@ isc___errno2result(int posixerrno, bool dolog, const char *file, case ENAMETOOLONG: case EBADF: return (ISC_R_INVALIDFILE); + case EISDIR: + return (ISC_R_NOTFILE); case ENOENT: return (ISC_R_FILENOTFOUND); case EACCES: diff --git a/lib/isc/lex.c b/lib/isc/lex.c index 8ab36828739..b09c09635ad 100644 --- a/lib/isc/lex.c +++ b/lib/isc/lex.c @@ -27,6 +27,8 @@ #include #include +#include "errno2result.h" + typedef struct inputsource { isc_result_t result; bool is_file; @@ -425,7 +427,9 @@ isc_lex_gettoken(isc_lex_t *lex, unsigned int options, isc_token_t *tokenp) { #endif /* if defined(HAVE_FLOCKFILE) && defined(HAVE_GETC_UNLOCKED) */ if (c == EOF) { if (ferror(stream)) { - source->result = ISC_R_IOERROR; + source->result = + isc__errno2result( + errno); result = source->result; goto done; }