summaryrefslogtreecommitdiff
path: root/compat.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2002-01-22 23:26:38 +1100
committerDamien Miller <djm@mindrot.org>2002-01-22 23:26:38 +1100
commit0e3b87279c3f20630e616b4de1be7cae815682dd (patch)
tree171bd0872677cd0938cb223fe7c7fbf69fdd6e15 /compat.c
parent1a534ae97fc1d9e75384d8df44fef7f788c3629d (diff)
- markus@cvs.openbsd.org 2002/01/13 17:57:37
[auth2.c auth2-chall.c compat.c sshconnect2.c sshd.c] use buffer API and avoid static strings of fixed size; ok provos@/mouring@
Diffstat (limited to 'compat.c')
-rw-r--r--compat.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/compat.c b/compat.c
index 3f8d1c041..6a9ba4653 100644
--- a/compat.c
+++ b/compat.c
@@ -23,8 +23,9 @@
23 */ 23 */
24 24
25#include "includes.h" 25#include "includes.h"
26RCSID("$OpenBSD: compat.c,v 1.56 2001/12/19 07:18:56 deraadt Exp $"); 26RCSID("$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)
182char * 183char *
183compat_cipher_proposal(char *cipher_prop) 184compat_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);