summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2014-05-13 22:54:19 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2014-05-13 22:54:19 +0000
commit3464c18d1fdda01444b65f52f810987ed7d85c43 (patch)
tree9bb362b27fc9b952b15d37c4fb20764ce2ca6852
parent97c95ac54ae291aa2ec59c068a4d1bad6aab2fa4 (diff)
Don't allow multiple buffers with the same name, from Thomas Adam.
-rw-r--r--usr.bin/tmux/paste.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/usr.bin/tmux/paste.c b/usr.bin/tmux/paste.c
index 1f9626fa56f..bfd531c9bfd 100644
--- a/usr.bin/tmux/paste.c
+++ b/usr.bin/tmux/paste.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: paste.c,v 1.19 2014/05/13 07:34:35 nicm Exp $ */
+/* $OpenBSD: paste.c,v 1.20 2014/05/13 22:54:18 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -176,7 +176,7 @@ paste_add(char *data, size_t size)
int
paste_rename(const char *oldname, const char *newname, char **cause)
{
- struct paste_buffer *pb;
+ struct paste_buffer *pb, *pb_new;
if (cause != NULL)
*cause = NULL;
@@ -195,7 +195,14 @@ paste_rename(const char *oldname, const char *newname, char **cause)
pb = paste_get_name(oldname);
if (pb == NULL) {
if (cause != NULL)
- xasprintf(cause, "no buffer %s", oldname);
+ xasprintf(cause, "no buffer %s", oldname);
+ return (-1);
+ }
+
+ pb_new = paste_get_name(newname);
+ if (pb_new != NULL) {
+ if (cause != NULL)
+ xasprintf(cause, "buffer %s already exists", newname);
return (-1);
}