1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-10 09:58:01 +00:00

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]
This commit is contained in:
Jacob Nevins 2008-11-23 20:11:12 +00:00
parent 7da40ece76
commit c9326ad81b

View File

@ -495,15 +495,13 @@ static char *read_body(FILE * fp)
while (1) { while (1) {
c = fgetc(fp); c = fgetc(fp);
if (c == '\r' || c == '\n') { if (c == '\r' || c == '\n' || c == EOF) {
if (c != EOF) {
c = fgetc(fp); c = fgetc(fp);
if (c != '\r' && c != '\n' && c != EOF) if (c != '\r' && c != '\n')
ungetc(c, fp); ungetc(c, fp);
return text;
} }
if (c == EOF) { return text;
sfree(text);
return NULL;
} }
if (len + 1 >= size) { if (len + 1 >= size) {
size += 128; size += 128;