diff --git a/src/pem.c b/src/pem.c index 9059477e..2e68c74d 100644 --- a/src/pem.c +++ b/src/pem.c @@ -67,6 +67,8 @@ _libssh2_pem_parse(LIBSSH2_SESSION * session, int ret; do { + *line = '\0'; + if (readline(line, LINE_SIZE, fp)) { return -1; } @@ -91,12 +93,18 @@ _libssh2_pem_parse(LIBSSH2_SESSION * session, b64datalen += linelen; } + *line = '\0'; + if (readline(line, LINE_SIZE, fp)) { ret = -1; goto out; } } while (strcmp(line, headerend) != 0); + if (!b64data) { + return -1; + } + if (libssh2_base64_decode(session, (char**) data, datalen, b64data, b64datalen)) { ret = -1;