diff options
author | Jean-Francois Brousseau <jfb@cvs.openbsd.org> | 2004-12-06 21:13:50 +0000 |
---|---|---|
committer | Jean-Francois Brousseau <jfb@cvs.openbsd.org> | 2004-12-06 21:13:50 +0000 |
commit | f9cb54a7a4bb2711c0d028cc82fb05770fb11e0f (patch) | |
tree | f3c4f1f8e831504e19f16eb934e291457b6b9ce1 /usr.bin/cvs/util.c | |
parent | ff9bafeb0d201ee9eff719dedd6a13b355b27931 (diff) |
reorder some of the code for argument vector splitting so we don't
overflow the array and we don't produce weird results if the last
character of the line is an escape character (bogus!)
Diffstat (limited to 'usr.bin/cvs/util.c')
-rw-r--r-- | usr.bin/cvs/util.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/usr.bin/cvs/util.c b/usr.bin/cvs/util.c index 949d882ec45..aef655f1960 100644 --- a/usr.bin/cvs/util.c +++ b/usr.bin/cvs/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.15 2004/12/06 21:03:13 deraadt Exp $ */ +/* $OpenBSD: util.c,v 1.16 2004/12/06 21:13:49 jfb Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -393,12 +393,13 @@ cvs_getargv(const char *line, char **argv, int argvlen) i = 0; memset(qbuf, 0, sizeof(qbuf)); while (*lp != '"') { + if (*lp == '\\') + lp++; if (*lp == '\0') { cvs_log(LP_ERR, "no terminating quote"); err++; break; - } else if (*lp == '\\') - lp++; + } qbuf[i++] = *lp++; if (i == sizeof(qbuf)) { @@ -418,6 +419,11 @@ cvs_getargv(const char *line, char **argv, int argvlen) arg = cp; } + if (argc == argvlen) { + err++; + break; + } + argv[argc] = strdup(arg); if (argv[argc] == NULL) { cvs_log(LP_ERRNO, "failed to copy argument"); @@ -450,7 +456,8 @@ cvs_freeargv(char **argv, int argc) int i; for (i = 0; i < argc; i++) - free(argv[i]); + if (argv[i] != NULL) + free(argv[i]); } |