ad7b3b
diff --git a/lib/isc/lex.c b/lib/isc/lex.c
b626a2
index cd44fe3..5b7c539 100644
ad7b3b
--- a/lib/isc/lex.c
ad7b3b
+++ b/lib/isc/lex.c
b626a2
@@ -27,6 +27,8 @@
b626a2
 #include <isc/string.h>
b626a2
 #include <isc/util.h>
Adam Tkac 3475d4
 
b626a2
+#include "../errno2result.h"
Adam Tkac 3475d4
+
b626a2
 typedef struct inputsource {
b626a2
 	isc_result_t result;
b626a2
 	bool is_file;
b626a2
@@ -422,7 +424,7 @@ isc_lex_gettoken(isc_lex_t *lex, unsigned int options, isc_token_t *tokenp) {
b626a2
 #endif /* if defined(HAVE_FLOCKFILE) && defined(HAVE_GETC_UNLOCKED) */
b626a2
 				if (c == EOF) {
b626a2
 					if (ferror(stream)) {
b626a2
-						source->result = ISC_R_IOERROR;
b626a2
+						source->result = isc__errno2result(errno);
b626a2
 						result = source->result;
Adam Tkac 3475d4
 						goto done;
Adam Tkac 3475d4
 					}
ad7b3b
diff --git a/lib/isc/unix/errno2result.c b/lib/isc/unix/errno2result.c
b626a2
index e3e2644..5e58600 100644
ad7b3b
--- a/lib/isc/unix/errno2result.c
ad7b3b
+++ b/lib/isc/unix/errno2result.c
b626a2
@@ -37,6 +37,7 @@ isc___errno2result(int posixerrno, bool dolog, const char *file,
b626a2
 	case EINVAL: /* XXX sometimes this is not for files */
Adam Tkac 3475d4
 	case ENAMETOOLONG:
Adam Tkac 3475d4
 	case EBADF:
Adam Tkac 3475d4
+	case EISDIR:
Adam Tkac 3475d4
 		return (ISC_R_INVALIDFILE);
Adam Tkac 3475d4
 	case ENOENT:
Adam Tkac 3475d4
 		return (ISC_R_FILENOTFOUND);