summaryrefslogtreecommitdiff
path: root/auth2-chall.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 /auth2-chall.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 'auth2-chall.c')
-rw-r--r--auth2-chall.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/auth2-chall.c b/auth2-chall.c
index a1f96392e..9f1d93275 100644
--- a/auth2-chall.c
+++ b/auth2-chall.c
@@ -23,10 +23,11 @@
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25#include "includes.h" 25#include "includes.h"
26RCSID("$OpenBSD: auth2-chall.c,v 1.15 2002/01/11 23:02:51 markus Exp $"); 26RCSID("$OpenBSD: auth2-chall.c,v 1.16 2002/01/13 17:57:37 markus Exp $");
27 27
28#include "ssh2.h" 28#include "ssh2.h"
29#include "auth.h" 29#include "auth.h"
30#include "buffer.h"
30#include "packet.h" 31#include "packet.h"
31#include "xmalloc.h" 32#include "xmalloc.h"
32#include "dispatch.h" 33#include "dispatch.h"
@@ -68,22 +69,25 @@ static KbdintAuthctxt *
68kbdint_alloc(const char *devs) 69kbdint_alloc(const char *devs)
69{ 70{
70 KbdintAuthctxt *kbdintctxt; 71 KbdintAuthctxt *kbdintctxt;
72 Buffer b;
71 int i; 73 int i;
72 char buf[1024];
73 74
74 kbdintctxt = xmalloc(sizeof(KbdintAuthctxt)); 75 kbdintctxt = xmalloc(sizeof(KbdintAuthctxt));
75 if (strcmp(devs, "") == 0) { 76 if (strcmp(devs, "") == 0) {
76 buf[0] = '\0'; 77 buffer_init(&b);
77 for (i = 0; devices[i]; i++) { 78 for (i = 0; devices[i]; i++) {
78 if (i != 0) 79 if (buffer_len(&b) > 0)
79 strlcat(buf, ",", sizeof(buf)); 80 buffer_append(&b, ",", 1);
80 strlcat(buf, devices[i]->name, sizeof(buf)); 81 buffer_append(&b, devices[i]->name,
82 strlen(devices[i]->name));
81 } 83 }
82 debug("kbdint_alloc: devices '%s'", buf); 84 buffer_append(&b, "\0", 1);
83 kbdintctxt->devices = xstrdup(buf); 85 kbdintctxt->devices = xstrdup(buffer_ptr(&b));
86 buffer_free(&b);
84 } else { 87 } else {
85 kbdintctxt->devices = xstrdup(devs); 88 kbdintctxt->devices = xstrdup(devs);
86 } 89 }
90 debug("kbdint_alloc: devices '%s'", kbdintctxt->devices);
87 kbdintctxt->ctxt = NULL; 91 kbdintctxt->ctxt = NULL;
88 kbdintctxt->device = NULL; 92 kbdintctxt->device = NULL;
89 93