diff options
author | Tobias Stoeckmann <tobias@cvs.openbsd.org> | 2007-09-10 10:29:13 +0000 |
---|---|---|
committer | Tobias Stoeckmann <tobias@cvs.openbsd.org> | 2007-09-10 10:29:13 +0000 |
commit | 20f1fc7d4ef7ef7b5c838e870f7e81dc784e5d1b (patch) | |
tree | 36650155c0b51230e5e128c117a0b02feaa2d2e6 | |
parent | 4f985f76e48025121fe39b9f1d3f2abb0002db64 (diff) |
Fixed segmentation fault that occured during .cvsrc parsing if an invalid
cvs command has been specified.
Spotted by Mathias De Belder <mathias at woei dot be> who also supplied a
patch, although I took his second suggestion.
OK joris@
-rw-r--r-- | usr.bin/cvs/cvs.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/usr.bin/cvs/cvs.c b/usr.bin/cvs/cvs.c index 9d4c3270c00..3c860bfa35d 100644 --- a/usr.bin/cvs/cvs.c +++ b/usr.bin/cvs/cvs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cvs.c,v 1.131 2007/09/07 23:30:30 tobias Exp $ */ +/* $OpenBSD: cvs.c,v 1.132 2007/09/10 10:29:12 tobias Exp $ */ /* * Copyright (c) 2006, 2007 Joris Vink <joris@openbsd.org> * Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org> @@ -184,6 +184,16 @@ main(int argc, char **argv) else if (!S_ISDIR(st.st_mode)) fatal("`%s' is not valid temporary directory", cvs_tmpdir); + cmdp = cvs_findcmd(cvs_command); + if (cmdp == NULL) { + fprintf(stderr, "Unknown command: `%s'\n\n", cvs_command); + fprintf(stderr, "CVS commands are:\n"); + for (i = 0; cvs_cdt[i] != NULL; i++) + fprintf(stderr, "\t%-16s%s\n", + cvs_cdt[i]->cmd_name, cvs_cdt[i]->cmd_descr); + exit(1); + } + if (cvs_readrc == 1 && cvs_homedir != NULL) { cvs_read_rcfile(); @@ -206,16 +216,6 @@ main(int argc, char **argv) signal(SIGALRM, sighandler); signal(SIGPIPE, sighandler); - cmdp = cvs_findcmd(cvs_command); - if (cmdp == NULL) { - fprintf(stderr, "Unknown command: `%s'\n\n", cvs_command); - fprintf(stderr, "CVS commands are:\n"); - for (i = 0; cvs_cdt[i] != NULL; i++) - fprintf(stderr, "\t%-16s%s\n", - cvs_cdt[i]->cmd_name, cvs_cdt[i]->cmd_descr); - exit(1); - } - cvs_cmdop = cmdp->cmd_op; cmd_argc = 0; |