summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortobias <tobias@openbsd.org>2008-04-24 19:16:49 +0000
committertobias <tobias@openbsd.org>2008-04-24 19:16:49 +0000
commit3dbbe18db0b5a9f455fb117d4d1a0e8ebfedb3ef (patch)
tree07724d7398cefd0cbd9d147eef5ff7062c19c352
parentUse a fixed string in case of vasprintf() error instead of relying on (diff)
downloadwireguard-openbsd-3dbbe18db0b5a9f455fb117d4d1a0e8ebfedb3ef.tar.xz
wireguard-openbsd-3dbbe18db0b5a9f455fb117d4d1a0e8ebfedb3ef.zip
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.c10
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];