diff --git a/include/libssh2.h b/include/libssh2.h index 1580ba5e..bc4f2d47 100644 --- a/include/libssh2.h +++ b/include/libssh2.h @@ -405,6 +405,7 @@ typedef struct _LIBSSH2_POLLFD { #define LIBSSH2_ERROR_SOCKET_RECV -43 #define LIBSSH2_ERROR_ENCRYPT -44 #define LIBSSH2_ERROR_BAD_SOCKET -45 +#define LIBSSH2_ERROR_KNOWN_HOSTS -46 /* this is a define to provide the old (<= 1.2.7) name */ #define LIBSSH2_ERROR_BANNER_NONE LIBSSH2_ERROR_BANNER_RECV diff --git a/src/knownhost.c b/src/knownhost.c index c58dfbb2..1087bc28 100644 --- a/src/knownhost.c +++ b/src/knownhost.c @@ -910,8 +910,11 @@ libssh2_knownhost_readfile(LIBSSH2_KNOWNHOSTS *hosts, file = fopen(filename, "r"); if(file) { while(fgets(buf, sizeof(buf), file)) { - if(libssh2_knownhost_readline(hosts, buf, strlen(buf), type)) + if(libssh2_knownhost_readline(hosts, buf, strlen(buf), type)) { + num = _libssh2_error(hosts->session, LIBSSH2_ERROR_KNOWN_HOSTS, + "Failed to parse known hosts file"); break; + } num++; } fclose(file);