diff options
author | Tobias Stoeckmann <tobias@cvs.openbsd.org> | 2008-01-28 21:26:52 +0000 |
---|---|---|
committer | Tobias Stoeckmann <tobias@cvs.openbsd.org> | 2008-01-28 21:26:52 +0000 |
commit | 7ddd256f9e4ad13c847aeab5c64fb71f1bf86764 (patch) | |
tree | 1bad658f4cb32c62b5f5b13b61c0e5cd94f9125f /usr.bin/cvs/commit.c | |
parent | 2b4e648ef507f1c2554bb6b413eede833374537b (diff) |
checkout's options -m and -F are mutually exclusive. Also watch out to
properly free arguments if options are supplied multiple times.
OK ray@
> Diff from Igor Zinovik
Diffstat (limited to 'usr.bin/cvs/commit.c')
-rw-r--r-- | usr.bin/cvs/commit.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/usr.bin/cvs/commit.c b/usr.bin/cvs/commit.c index 994221f564d..be36858d079 100644 --- a/usr.bin/cvs/commit.c +++ b/usr.bin/cvs/commit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: commit.c,v 1.120 2008/01/28 20:31:07 tobias Exp $ */ +/* $OpenBSD: commit.c,v 1.121 2008/01/28 21:26:51 tobias Exp $ */ /* * Copyright (c) 2006 Joris Vink <joris@openbsd.org> * Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org> @@ -54,17 +54,22 @@ struct cvs_cmd cvs_cmd_commit = { int cvs_commit(int argc, char **argv) { - int ch; + int ch, Fflag, mflag; char *arg = "."; int flags; struct cvs_recursion cr; flags = CR_RECURSE_DIRS; + Fflag = mflag = 0; while ((ch = getopt(argc, argv, cvs_cmd_commit.cmd_opts)) != -1) { switch (ch) { case 'F': + /* free previously assigned value */ + if (logmsg != NULL) + xfree(logmsg); logmsg = cvs_logmsg_read(optarg); + Fflag = 1; break; case 'f': break; @@ -72,7 +77,11 @@ cvs_commit(int argc, char **argv) flags &= ~CR_RECURSE_DIRS; break; case 'm': + /* free previously assigned value */ + if (logmsg != NULL) + xfree(logmsg); logmsg = xstrdup(optarg); + mflag = 1; break; case 'R': flags |= CR_RECURSE_DIRS; @@ -87,6 +96,10 @@ cvs_commit(int argc, char **argv) argc -= optind; argv += optind; + /* -F and -m are mutually exclusive */ + if (Fflag && mflag) + fatal("cannot specify both a log file and a message"); + TAILQ_INIT(&files_affected); TAILQ_INIT(&files_added); TAILQ_INIT(&files_removed); |