summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTobias Stoeckmann <tobias@cvs.openbsd.org>2008-05-30 16:11:33 +0000
committerTobias Stoeckmann <tobias@cvs.openbsd.org>2008-05-30 16:11:33 +0000
commit91087393bd468446ebf5e55ab93e4c6dd41a42d1 (patch)
tree951892e55b39cdeaecb133c60163d06cfc4b8f1e /usr.bin
parentfe17b3bec9866a9c29af80138b2037436f6af632 (diff)
Set up cmdp before first possible call of fatal to avoid NULL pointer
dereference in logging code. Spotted by Igor Zinovik. ok joris
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/cvs/cvs.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/usr.bin/cvs/cvs.c b/usr.bin/cvs/cvs.c
index 6e3d0b3729e..0de5c870d56 100644
--- a/usr.bin/cvs/cvs.c
+++ b/usr.bin/cvs/cvs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cvs.c,v 1.145 2008/05/28 17:12:00 tobias Exp $ */
+/* $OpenBSD: cvs.c,v 1.146 2008/05/30 16:11:32 tobias Exp $ */
/*
* Copyright (c) 2006, 2007 Joris Vink <joris@openbsd.org>
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
@@ -217,16 +217,6 @@ main(int argc, char **argv)
if (argc == 0)
usage();
- /*
- * check the tmp dir, either specified through
- * the environment variable TMPDIR, or via
- * the global option -T <dir>
- */
- if (stat(cvs_tmpdir, &st) == -1)
- fatal("stat failed on `%s': %s", cvs_tmpdir, strerror(errno));
- else if (!S_ISDIR(st.st_mode))
- fatal("`%s' is not valid temporary directory", cvs_tmpdir);
-
cmdp = cvs_findcmd(argv[0]);
if (cmdp == NULL) {
fprintf(stderr, "Unknown command: `%s'\n\n", argv[0]);
@@ -237,6 +227,16 @@ main(int argc, char **argv)
exit(1);
}
+ /*
+ * check the tmp dir, either specified through
+ * the environment variable TMPDIR, or via
+ * the global option -T <dir>
+ */
+ if (stat(cvs_tmpdir, &st) == -1)
+ fatal("stat failed on `%s': %s", cvs_tmpdir, strerror(errno));
+ else if (!S_ISDIR(st.st_mode))
+ fatal("`%s' is not valid temporary directory", cvs_tmpdir);
+
if (cvs_readrc == 1 && cvs_homedir != NULL) {
cvs_read_rcfile();