diff options
Diffstat (limited to 'compat.c')
-rw-r--r-- | compat.c | 18 |
1 files changed, 10 insertions, 8 deletions
@@ -23,8 +23,9 @@ | |||
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include "includes.h" | 25 | #include "includes.h" |
26 | RCSID("$OpenBSD: compat.c,v 1.56 2001/12/19 07:18:56 deraadt Exp $"); | 26 | RCSID("$OpenBSD: compat.c,v 1.57 2002/01/13 17:57:37 markus Exp $"); |
27 | 27 | ||
28 | #include "buffer.h" | ||
28 | #include "packet.h" | 29 | #include "packet.h" |
29 | #include "xmalloc.h" | 30 | #include "xmalloc.h" |
30 | #include "compat.h" | 31 | #include "compat.h" |
@@ -182,24 +183,25 @@ proto_spec(const char *spec) | |||
182 | char * | 183 | char * |
183 | compat_cipher_proposal(char *cipher_prop) | 184 | compat_cipher_proposal(char *cipher_prop) |
184 | { | 185 | { |
186 | Buffer b; | ||
185 | char *orig_prop, *fix_ciphers; | 187 | char *orig_prop, *fix_ciphers; |
186 | char *cp, *tmp; | 188 | char *cp, *tmp; |
187 | size_t len; | ||
188 | 189 | ||
189 | if (!(datafellows & SSH_BUG_BIGENDIANAES)) | 190 | if (!(datafellows & SSH_BUG_BIGENDIANAES)) |
190 | return(cipher_prop); | 191 | return(cipher_prop); |
191 | 192 | ||
192 | len = strlen(cipher_prop) + 1; | 193 | buffer_init(&b); |
193 | fix_ciphers = xmalloc(len); | ||
194 | *fix_ciphers = '\0'; | ||
195 | tmp = orig_prop = xstrdup(cipher_prop); | 194 | tmp = orig_prop = xstrdup(cipher_prop); |
196 | while ((cp = strsep(&tmp, ",")) != NULL) { | 195 | while ((cp = strsep(&tmp, ",")) != NULL) { |
197 | if (strncmp(cp, "aes", 3) && strncmp(cp, "rijndael", 8)) { | 196 | if (strncmp(cp, "aes", 3) && strncmp(cp, "rijndael", 8)) { |
198 | if (*fix_ciphers) | 197 | if (buffer_len(&b) > 0) |
199 | strlcat(fix_ciphers, ",", len); | 198 | buffer_append(&b, ",", 1); |
200 | strlcat(fix_ciphers, cp, len); | 199 | buffer_append(&b, cp, strlen(cp)); |
201 | } | 200 | } |
202 | } | 201 | } |
202 | buffer_append(&b, "\0", 1); | ||
203 | fix_ciphers = xstrdup(buffer_ptr(&b)); | ||
204 | buffer_free(&b); | ||
203 | xfree(orig_prop); | 205 | xfree(orig_prop); |
204 | debug2("Original cipher proposal: %s", cipher_prop); | 206 | debug2("Original cipher proposal: %s", cipher_prop); |
205 | debug2("Compat cipher proposal: %s", fix_ciphers); | 207 | debug2("Compat cipher proposal: %s", fix_ciphers); |