From c9326ad81b352076f29ceeb98dbaa7f368ed4d91 Mon Sep 17 00:00:00 2001 From: Jacob Nevins Date: Sun, 23 Nov 2008 20:11:12 +0000 Subject: [PATCH] Make key file import robust against a PPK file that has somehow lost its final newline. From Debian bug #414784, based on a patch by Justin Pryzby. [originally from svn r8323] --- sshpubk.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/sshpubk.c b/sshpubk.c index f35febe3..4536e856 100644 --- a/sshpubk.c +++ b/sshpubk.c @@ -495,16 +495,14 @@ static char *read_body(FILE * fp) while (1) { c = fgetc(fp); - if (c == '\r' || c == '\n') { - c = fgetc(fp); - if (c != '\r' && c != '\n' && c != EOF) - ungetc(c, fp); + if (c == '\r' || c == '\n' || c == EOF) { + if (c != EOF) { + c = fgetc(fp); + if (c != '\r' && c != '\n') + ungetc(c, fp); + } return text; } - if (c == EOF) { - sfree(text); - return NULL; - } if (len + 1 >= size) { size += 128; text = sresize(text, size, char);