Bugzilla – Attachment 1086 Details for
Bug 1157
ssh-keygen doesn't handle DOS line breaks
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Make ssh-keygen accept CR, LF or CRLF in keys take 4
openssh-keygen-newline.patch (text/plain), 1.79 KB, created by
Darren Tucker
on 2006-02-26 16:32:36 AEDT
(
hide
)
Description:
Make ssh-keygen accept CR, LF or CRLF in keys take 4
Filename:
MIME Type:
Creator:
Darren Tucker
Created:
2006-02-26 16:32:36 AEDT
Size:
1.79 KB
patch
obsolete
>Index: ssh-keygen.c >=================================================================== >RCS file: /usr/local/src/security/openssh/cvs/openssh_cvs/ssh-keygen.c,v >retrieving revision 1.141 >diff -u -p -r1.141 ssh-keygen.c >--- ssh-keygen.c 29 Nov 2005 02:10:25 -0000 1.141 >+++ ssh-keygen.c 26 Feb 2006 05:17:58 -0000 >@@ -302,13 +302,45 @@ do_convert_private_ssh2_from_blob(u_char > return key; > } > >+static int >+get_line(FILE *fp, char *line, size_t len) >+{ >+ int c; >+ size_t pos = 0; >+ >+ if (len > INT_MAX) >+ return -1; >+ >+ line[0] = '\0'; >+ while ((c = fgetc(fp)) != EOF) { >+ if (pos >= len - 1) { >+ fprintf(stderr, "input line too long.\n"); >+ exit(1); >+ } >+ switch(c) { >+ case '\r': >+ c = fgetc(fp); >+ if (c != EOF && c != '\n' && ungetc(c, fp) == EOF) { >+ fprintf(stderr, "unget: %s\n", strerror(errno)); >+ exit(1); >+ } >+ return 0; >+ case '\n': >+ return 0; >+ } >+ line[pos++] = c; >+ line[pos] = '\0'; >+ } >+ return 0; >+} >+ > static void > do_convert_from_ssh2(struct passwd *pw) > { > Key *k; > int blen; > u_int len; >- char line[1024], *p; >+ char line[1024]; > u_char blob[8096]; > char encoded[8096]; > struct stat st; >@@ -327,12 +359,9 @@ do_convert_from_ssh2(struct passwd *pw) > exit(1); > } > encoded[0] = '\0'; >- while (fgets(line, sizeof(line), fp)) { >- if (!(p = strchr(line, '\n'))) { >- fprintf(stderr, "input line too long.\n"); >- exit(1); >- } >- if (p > line && p[-1] == '\\') >+ while (get_line(fp, line, sizeof(line)) == 0) { >+ len = strlen(line); >+ if (line[len - 1] == '\\') > escaped++; > if (strncmp(line, "----", 4) == 0 || > strstr(line, ": ") != NULL) { >@@ -349,7 +378,6 @@ do_convert_from_ssh2(struct passwd *pw) > /* fprintf(stderr, "escaped: %s", line); */ > continue; > } >- *p = '\0'; > strlcat(encoded, line, sizeof(encoded)); > } > len = strlen(encoded);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 1157
:
1067
|
1068
|
1069
|
1070
|
1074
|
1078
|
1086
|
1087
|
1091