summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorotto <otto@openbsd.org>2007-02-22 19:11:13 +0000
committerotto <otto@openbsd.org>2007-02-22 19:11:13 +0000
commit168f4dca489f790262d4e96fcbd2eb26100bcf1e (patch)
treed1f93a3934f3546e278a0163dafb52686c2829ed
parentAdded changes to dump all tables not just DSDT (diff)
downloadwireguard-openbsd-168f4dca489f790262d4e96fcbd2eb26100bcf1e.tar.xz
wireguard-openbsd-168f4dca489f790262d4e96fcbd2eb26100bcf1e.zip
If a ,suffix file is given as an arg to ci and co, strip it. Avoids
potential disasters. Initial diff from niallo@, ok niallo@ joris@
-rw-r--r--usr.bin/rcs/ci.c7
-rw-r--r--usr.bin/rcs/co.c7
-rw-r--r--usr.bin/rcs/rcsutil.c22
-rw-r--r--usr.bin/rcs/rcsutil.h3
4 files changed, 35 insertions, 4 deletions
diff --git a/usr.bin/rcs/ci.c b/usr.bin/rcs/ci.c
index de47e53a13a..3afa7079d02 100644
--- a/usr.bin/rcs/ci.c
+++ b/usr.bin/rcs/ci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ci.c,v 1.193 2007/02/14 16:07:29 niallo Exp $ */
+/* $OpenBSD: ci.c,v 1.194 2007/02/22 19:11:13 otto Exp $ */
/*
* Copyright (c) 2005, 2006 Niall O'Higgins <niallo@openbsd.org>
* All rights reserved.
@@ -233,8 +233,13 @@ checkin_main(int argc, char **argv)
if ((pb.username = getlogin()) == NULL)
err(1, "getlogin");
+ /* If -x flag was not given, use default. */
+ if (rcs_suffixes == NULL)
+ rcs_suffixes = RCS_DEFAULT_SUFFIX;
+
for (i = 0; i < argc; i++) {
pb.filename = argv[i];
+ rcs_strip_suffix(pb.filename);
if ((workfile_fd = open(pb.filename, O_RDONLY)) == -1)
err(1, "%s", pb.filename);
diff --git a/usr.bin/rcs/co.c b/usr.bin/rcs/co.c
index 3888bacb427..aca34e660d9 100644
--- a/usr.bin/rcs/co.c
+++ b/usr.bin/rcs/co.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: co.c,v 1.103 2007/02/21 18:12:36 niallo Exp $ */
+/* $OpenBSD: co.c,v 1.104 2007/02/22 19:11:13 otto Exp $ */
/*
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
* All rights reserved.
@@ -149,12 +149,17 @@ checkout_main(int argc, char **argv)
if ((username = getlogin()) == NULL)
err(1, "getlogin");
+ /* If -x flag was not given, use default. */
+ if (rcs_suffixes == NULL)
+ rcs_suffixes = RCS_DEFAULT_SUFFIX;
+
for (i = 0; i < argc; i++) {
fd = rcs_choosefile(argv[i], fpath, sizeof(fpath));
if (fd < 0) {
warn("%s", fpath);
continue;
}
+ rcs_strip_suffix(argv[i]);
if (!(flags & QUIET))
(void)fprintf(stderr, "%s --> %s\n", fpath,
diff --git a/usr.bin/rcs/rcsutil.c b/usr.bin/rcs/rcsutil.c
index 633862235f6..11976adc86c 100644
--- a/usr.bin/rcs/rcsutil.c
+++ b/usr.bin/rcs/rcsutil.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsutil.c,v 1.27 2007/02/22 08:30:45 xsa Exp $ */
+/* $OpenBSD: rcsutil.c,v 1.28 2007/02/22 19:11:13 otto Exp $ */
/*
* Copyright (c) 2005, 2006 Joris Vink <joris@openbsd.org>
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
@@ -619,3 +619,23 @@ rcs_argv_destroy(struct rcs_argvector *av)
xfree(av->argv);
xfree(av);
}
+
+/*
+ * Strip suffix from filename.
+ */
+void
+rcs_strip_suffix(char *filename)
+{
+ char *p, *suffixes, *next, *ext;
+
+ if ((p = strrchr(filename, ',')) != NULL) {
+ suffixes = xstrdup(rcs_suffixes);
+ for (next = suffixes; (ext = strsep(&next, "/")) != NULL;) {
+ if (!strcmp(p, ext)) {
+ *p = '\0';
+ break;
+ }
+ }
+ xfree(suffixes);
+ }
+}
diff --git a/usr.bin/rcs/rcsutil.h b/usr.bin/rcs/rcsutil.h
index 0be527b4253..df36d7c7ccd 100644
--- a/usr.bin/rcs/rcsutil.h
+++ b/usr.bin/rcs/rcsutil.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsutil.h,v 1.11 2007/02/22 08:30:45 xsa Exp $ */
+/* $OpenBSD: rcsutil.h,v 1.12 2007/02/22 19:11:13 otto Exp $ */
/*
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
* All rights reserved.
@@ -67,5 +67,6 @@ void rcs_freelines(struct rcs_lines *);
int rcs_yesno(int);
struct rcs_argvector *rcs_strsplit(const char *, const char *);
void rcs_argv_destroy(struct rcs_argvector *);
+void rcs_strip_suffix(char *);
#endif /* RCSUTIL_H */