summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorRay Lai <ray@cvs.openbsd.org>2008-04-26 19:58:04 +0000
committerRay Lai <ray@cvs.openbsd.org>2008-04-26 19:58:04 +0000
commit90bab1cbf5f01344731ef8b28645a20e5c826dc2 (patch)
tree962ca981ea8ed516b00b5fc576c3bd578b510e56 /usr.bin
parent0d0e05efac0ccc59b1e2db2173290cc28ac1cbe7 (diff)
Duplicate envstr and free it on error instead of allocating for
each argument and freeing each argument on error. OK joris, tobias
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/rcs/rcsprog.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/usr.bin/rcs/rcsprog.c b/usr.bin/rcs/rcsprog.c
index f8144985b1a..f1474281b4d 100644
--- a/usr.bin/rcs/rcsprog.c
+++ b/usr.bin/rcs/rcsprog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsprog.c,v 1.142 2008/04/24 19:16:49 tobias Exp $ */
+/* $OpenBSD: rcsprog.c,v 1.143 2008/04/26 19:58:03 ray Exp $ */
/*
* Copyright (c) 2005 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -77,12 +77,10 @@ sighdlr(int sig)
int
rcs_init(char *envstr, char **argv, int argvlen)
{
- u_int i;
int argc, error;
- char linebuf[256], *lp, *cp;
+ char *linebuf, *lp, *cp;
- if (strlcpy(linebuf, envstr, sizeof(linebuf)) >= sizeof(linebuf))
- errx(1, "rcs_init: string truncation");
+ linebuf = xstrdup(envstr);
(void)memset(argv, 0, argvlen * sizeof(char *));
error = argc = 0;
@@ -98,13 +96,12 @@ rcs_init(char *envstr, char **argv, int argvlen)
break;
}
- argv[argc] = xstrdup(cp);
+ argv[argc] = cp;
argc++;
}
if (error != 0) {
- for (i = 0; i < (u_int)argc; i++)
- xfree(argv[i]);
+ xfree(linebuf);
argc = -1;
}