summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2019-05-28 18:30:31 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2019-05-28 18:30:31 +0000
commit0c68ea8f338d1044dd0b39a1a0565982332683ed (patch)
tree6087d6eebcd78798a927e9861bc956cc9e3d7a21
parentc6b4d79dd2bc5acb85e9b1f5073f0b57c0d18ae6 (diff)
Do not read past the end of the argument string if it is empty.
-rw-r--r--usr.bin/tmux/arguments.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/usr.bin/tmux/arguments.c b/usr.bin/tmux/arguments.c
index e00ea617da4..c583d22a37c 100644
--- a/usr.bin/tmux/arguments.c
+++ b/usr.bin/tmux/arguments.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: arguments.c,v 1.23 2019/05/27 12:16:27 nicm Exp $ */
+/* $OpenBSD: arguments.c,v 1.24 2019/05/28 18:30:30 nicm Exp $ */
/*
* Copyright (c) 2010 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -211,6 +211,8 @@ args_escape(const char *s)
char *escaped, *result;
int flags;
+ if (*s == '\0')
+ return (xstrdup(s));
if ((strchr(quoted, s[0]) != NULL || s[0] == '~') && s[1] == '\0') {
xasprintf(&escaped, "\\%c", s[0]);
return (escaped);