summaryrefslogtreecommitdiff
path: root/sshd.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 /sshd.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 'sshd.c')
-rw-r--r--sshd.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/sshd.c b/sshd.c
index d86e683b1..2ecf18cde 100644
--- a/sshd.c
+++ b/sshd.c
@@ -40,7 +40,7 @@
40 */ 40 */
41 41
42#include "includes.h" 42#include "includes.h"
43RCSID("$OpenBSD: sshd.c,v 1.222 2001/12/28 14:50:54 markus Exp $"); 43RCSID("$OpenBSD: sshd.c,v 1.223 2002/01/13 17:57:37 markus Exp $");
44 44
45#include <openssl/dh.h> 45#include <openssl/dh.h>
46#include <openssl/bn.h> 46#include <openssl/bn.h>
@@ -480,9 +480,11 @@ destroy_sensitive_data(void)
480static char * 480static char *
481list_hostkey_types(void) 481list_hostkey_types(void)
482{ 482{
483 static char buf[1024]; 483 Buffer b;
484 char *p;
484 int i; 485 int i;
485 buf[0] = '\0'; 486
487 buffer_init(&b);
486 for (i = 0; i < options.num_host_key_files; i++) { 488 for (i = 0; i < options.num_host_key_files; i++) {
487 Key *key = sensitive_data.host_keys[i]; 489 Key *key = sensitive_data.host_keys[i];
488 if (key == NULL) 490 if (key == NULL)
@@ -490,16 +492,18 @@ list_hostkey_types(void)
490 switch (key->type) { 492 switch (key->type) {
491 case KEY_RSA: 493 case KEY_RSA:
492 case KEY_DSA: 494 case KEY_DSA:
493 strlcat(buf, key_ssh_name(key), sizeof buf); 495 if (buffer_len(&b) > 0)
494 strlcat(buf, ",", sizeof buf); 496 buffer_append(&b, ",", 1);
497 p = key_ssh_name(key);
498 buffer_append(&b, p, strlen(p));
495 break; 499 break;
496 } 500 }
497 } 501 }
498 i = strlen(buf); 502 buffer_append(&b, "\0", 1);
499 if (i > 0 && buf[i-1] == ',') 503 p = xstrdup(buffer_ptr(&b));
500 buf[i-1] = '\0'; 504 buffer_free(&b);
501 debug("list_hostkey_types: %s", buf); 505 debug("list_hostkey_types: %s", p);
502 return buf; 506 return p;
503} 507}
504 508
505static Key * 509static Key *