diff options
author | Tobias Stoeckmann <tobias@cvs.openbsd.org> | 2008-04-24 19:16:50 +0000 |
---|---|---|
committer | Tobias Stoeckmann <tobias@cvs.openbsd.org> | 2008-04-24 19:16:50 +0000 |
commit | 4f9e1ab3a6ccc4582120bd25ea39d4401bd852bb (patch) | |
tree | 1e5c80bc489f42761bdac6e24bd0fe40c7dd9c51 | |
parent | 81d526270463844aec19caa761aa604da4337704 (diff) |
Prevent overflow of cmd_argv if RCS_INIT and command line arguments
exceed buffer size (diff based on OpenCVS code).
ok ray, xsa
-rw-r--r-- | usr.bin/rcs/rcsprog.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/usr.bin/rcs/rcsprog.c b/usr.bin/rcs/rcsprog.c index 4354eead314..f8144985b1a 100644 --- a/usr.bin/rcs/rcsprog.c +++ b/usr.bin/rcs/rcsprog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsprog.c,v 1.141 2008/03/04 16:43:51 joris Exp $ */ +/* $OpenBSD: rcsprog.c,v 1.142 2008/04/24 19:16:49 tobias Exp $ */ /* * Copyright (c) 2005 Jean-Francois Brousseau <jfb@openbsd.org> * All rights reserved. @@ -127,10 +127,8 @@ main(int argc, char **argv) if ((rcsinit = getenv("RCSINIT")) != NULL) { ret = rcs_init(rcsinit, cmd_argv + 1, RCS_CMD_MAXARG - 1); - if (ret < 0) { - warnx("failed to prepend RCSINIT options"); - exit (1); - } + if (ret < 0) + errx(1, "failed to prepend RCSINIT options"); cmd_argc += ret; } @@ -138,6 +136,8 @@ main(int argc, char **argv) if ((rcs_tmpdir = getenv("TMPDIR")) == NULL) rcs_tmpdir = RCS_TMPDIR_DEFAULT; + if (argc + cmd_argc >= RCS_CMD_MAXARG) + errx(1, "too many arguments"); for (ret = 1; ret < argc; ret++) cmd_argv[cmd_argc++] = argv[ret]; |