diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | ssh-keygen.c | 42 |
2 files changed, 39 insertions, 10 deletions
@@ -215,6 +215,11 @@ | |||
215 | Set TCP_NODELAY for all connections not just "interactive" ones. Fixes | 215 | Set TCP_NODELAY for all connections not just "interactive" ones. Fixes |
216 | poor performance and protocol stalls under some network conditions (mindrot | 216 | poor performance and protocol stalls under some network conditions (mindrot |
217 | bugs #556 and #981). Patch originally from markus@, ok djm@ | 217 | bugs #556 and #981). Patch originally from markus@, ok djm@ |
218 | - dtucker@cvs.openbsd.org 2006/03/13 08:43:16 | ||
219 | [ssh-keygen.c] | ||
220 | Make ssh-keygen handle CR and CRLF line termination when converting IETF | ||
221 | format keys, in adition to vanilla LF. mindrot #1157, tested by Chris | ||
222 | Pepper, ok djm@ | ||
218 | 223 | ||
219 | 20060313 | 224 | 20060313 |
220 | - (dtucker) [configure.ac] Bug #1171: Don't use printf("%lld", longlong) | 225 | - (dtucker) [configure.ac] Bug #1171: Don't use printf("%lld", longlong) |
@@ -4116,4 +4121,4 @@ | |||
4116 | - (djm) Trim deprecated options from INSTALL. Mention UsePAM | 4121 | - (djm) Trim deprecated options from INSTALL. Mention UsePAM |
4117 | - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu | 4122 | - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu |
4118 | 4123 | ||
4119 | $Id: ChangeLog,v 1.4201 2006/03/15 01:05:22 djm Exp $ | 4124 | $Id: ChangeLog,v 1.4202 2006/03/15 01:05:40 djm Exp $ |
diff --git a/ssh-keygen.c b/ssh-keygen.c index 8acbf7783..bea4ed59b 100644 --- a/ssh-keygen.c +++ b/ssh-keygen.c | |||
@@ -12,7 +12,7 @@ | |||
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include "includes.h" | 14 | #include "includes.h" |
15 | RCSID("$OpenBSD: ssh-keygen.c,v 1.136 2006/02/20 17:19:54 stevesk Exp $"); | 15 | RCSID("$OpenBSD: ssh-keygen.c,v 1.137 2006/03/13 08:43:16 dtucker Exp $"); |
16 | 16 | ||
17 | #include <sys/types.h> | 17 | #include <sys/types.h> |
18 | #include <sys/stat.h> | 18 | #include <sys/stat.h> |
@@ -305,13 +305,42 @@ do_convert_private_ssh2_from_blob(u_char *blob, u_int blen) | |||
305 | return key; | 305 | return key; |
306 | } | 306 | } |
307 | 307 | ||
308 | static int | ||
309 | get_line(FILE *fp, char *line, size_t len) | ||
310 | { | ||
311 | int c; | ||
312 | size_t pos = 0; | ||
313 | |||
314 | line[0] = '\0'; | ||
315 | while ((c = fgetc(fp)) != EOF) { | ||
316 | if (pos >= len - 1) { | ||
317 | fprintf(stderr, "input line too long.\n"); | ||
318 | exit(1); | ||
319 | } | ||
320 | switch(c) { | ||
321 | case '\r': | ||
322 | c = fgetc(fp); | ||
323 | if (c != EOF && c != '\n' && ungetc(c, fp) == EOF) { | ||
324 | fprintf(stderr, "unget: %s\n", strerror(errno)); | ||
325 | exit(1); | ||
326 | } | ||
327 | return pos; | ||
328 | case '\n': | ||
329 | return pos; | ||
330 | } | ||
331 | line[pos++] = c; | ||
332 | line[pos] = '\0'; | ||
333 | } | ||
334 | return pos; | ||
335 | } | ||
336 | |||
308 | static void | 337 | static void |
309 | do_convert_from_ssh2(struct passwd *pw) | 338 | do_convert_from_ssh2(struct passwd *pw) |
310 | { | 339 | { |
311 | Key *k; | 340 | Key *k; |
312 | int blen; | 341 | int blen; |
313 | u_int len; | 342 | u_int len; |
314 | char line[1024], *p; | 343 | char line[1024]; |
315 | u_char blob[8096]; | 344 | u_char blob[8096]; |
316 | char encoded[8096]; | 345 | char encoded[8096]; |
317 | struct stat st; | 346 | struct stat st; |
@@ -330,12 +359,8 @@ do_convert_from_ssh2(struct passwd *pw) | |||
330 | exit(1); | 359 | exit(1); |
331 | } | 360 | } |
332 | encoded[0] = '\0'; | 361 | encoded[0] = '\0'; |
333 | while (fgets(line, sizeof(line), fp)) { | 362 | while ((blen = get_line(fp, line, sizeof(line))) != -1) { |
334 | if (!(p = strchr(line, '\n'))) { | 363 | if (line[blen - 1] == '\\') |
335 | fprintf(stderr, "input line too long.\n"); | ||
336 | exit(1); | ||
337 | } | ||
338 | if (p > line && p[-1] == '\\') | ||
339 | escaped++; | 364 | escaped++; |
340 | if (strncmp(line, "----", 4) == 0 || | 365 | if (strncmp(line, "----", 4) == 0 || |
341 | strstr(line, ": ") != NULL) { | 366 | strstr(line, ": ") != NULL) { |
@@ -352,7 +377,6 @@ do_convert_from_ssh2(struct passwd *pw) | |||
352 | /* fprintf(stderr, "escaped: %s", line); */ | 377 | /* fprintf(stderr, "escaped: %s", line); */ |
353 | continue; | 378 | continue; |
354 | } | 379 | } |
355 | *p = '\0'; | ||
356 | strlcat(encoded, line, sizeof(encoded)); | 380 | strlcat(encoded, line, sizeof(encoded)); |
357 | } | 381 | } |
358 | len = strlen(encoded); | 382 | len = strlen(encoded); |