summaryrefslogtreecommitdiffstats
path: root/misc.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2003-09-22 13:04:23 +0200
committerDarren Tucker <dtucker@zip.com.au>2003-09-22 13:04:23 +0200
commitfb16b2411eda857cd358dc4c9c63b66edc217a51 (patch)
treeb1959332991a29ddf752a6e4e9e29a80d139d41c /misc.c
parent - markus@cvs.openbsd.org 2003/09/18 07:56:05 (diff)
downloadopenssh-fb16b2411eda857cd358dc4c9c63b66edc217a51.tar.xz
openssh-fb16b2411eda857cd358dc4c9c63b66edc217a51.zip
- markus@cvs.openbsd.org 2003/09/18 08:49:45
[deattack.c misc.c session.c ssh-agent.c] more buffer allocation fixes; from Solar Designer; CAN-2003-0682; ok millert@
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/misc.c b/misc.c
index c457a952c..ac616de02 100644
--- a/misc.c
+++ b/misc.c
@@ -23,7 +23,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: misc.c,v 1.21 2003/04/12 10:15:36 markus Exp $");
+RCSID("$OpenBSD: misc.c,v 1.22 2003/09/18 08:49:45 markus Exp $");
#include "misc.h"
#include "log.h"
@@ -308,18 +308,21 @@ addargs(arglist *args, char *fmt, ...)
{
va_list ap;
char buf[1024];
+ int nalloc;
va_start(ap, fmt);
vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
+ nalloc = args->nalloc;
if (args->list == NULL) {
- args->nalloc = 32;
+ nalloc = 32;
args->num = 0;
- } else if (args->num+2 >= args->nalloc)
- args->nalloc *= 2;
+ } else if (args->num+2 >= nalloc)
+ nalloc *= 2;
- args->list = xrealloc(args->list, args->nalloc * sizeof(char *));
+ args->list = xrealloc(args->list, nalloc * sizeof(char *));
+ args->nalloc = nalloc;
args->list[args->num++] = xstrdup(buf);
args->list[args->num] = NULL;
}