summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2016-04-25 17:05:54 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2016-04-25 17:05:54 +0000
commitdf287adb7c7b1cf5079daa71f526ea6e9a17c843 (patch)
tree824de5a9f12c7b135d89a20f176bb2a4b5635802
parent20776bf409d698a7bc2703600c208e4d42146a63 (diff)
Don't overwrite modifiers in the buffer when making UTF-8 strings,
append instead.
-rw-r--r--usr.bin/tmux/key-string.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.bin/tmux/key-string.c b/usr.bin/tmux/key-string.c
index 6124e53ce4f..e5a16e6b424 100644
--- a/usr.bin/tmux/key-string.c
+++ b/usr.bin/tmux/key-string.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: key-string.c,v 1.36 2016/03/18 07:28:27 nicm Exp $ */
+/* $OpenBSD: key-string.c,v 1.37 2016/04/25 17:05:53 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -226,6 +226,7 @@ key_string_lookup_key(key_code key)
char tmp[8];
u_int i;
struct utf8_data ud;
+ size_t off;
*out = '\0';
@@ -270,8 +271,9 @@ key_string_lookup_key(key_code key)
/* Is this a UTF-8 key? */
if (key > 127 && key < KEYC_BASE) {
if (utf8_split(key, &ud) == UTF8_DONE) {
- memcpy(out, ud.data, ud.size);
- out[ud.size] = '\0';
+ off = strlen(out);
+ memcpy(out + off, ud.data, ud.size);
+ out[off + ud.size] = '\0';
return (out);
}
}