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