pem.c: make sure there's a trailing zero and b64data is not NULL

... if there is no base64 data between PEM header and footer.
Reported by Coverity CID 89823.
This commit is contained in:
Marc Hoersken 2014-12-26 13:31:26 +01:00
parent 3835655f09
commit 8670f5da24

View File

@ -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;