From 3f0f6d2013dd19afa2033d7f33961ff1ed90000f Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Tue, 9 Oct 2018 18:07:52 +0100 Subject: [PATCH] Missing error message when loading a private key file. If the file is empty, or otherwise fails to start with a recognised 'PuTTY-User-Key-File' header line, we forgot to fill in the error message before returning failure, leading to a null pointer dereference. --- sshpubk.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sshpubk.c b/sshpubk.c index 2144bc2c..510eb585 100644 --- a/sshpubk.c +++ b/sshpubk.c @@ -612,8 +612,10 @@ struct ssh2_userkey *ssh2_load_userkey(const Filename *filename, } /* Read the first header line which contains the key type. */ - if (!read_header(fp, header)) + if (!read_header(fp, header)) { + error = "no header line found in key file"; goto error; + } if (0 == strcmp(header, "PuTTY-User-Key-File-2")) { old_fmt = 0; } else if (0 == strcmp(header, "PuTTY-User-Key-File-1")) {