summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/cmd-load-buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/tmux/cmd-load-buffer.c')
-rw-r--r--usr.bin/tmux/cmd-load-buffer.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/usr.bin/tmux/cmd-load-buffer.c b/usr.bin/tmux/cmd-load-buffer.c
index f60398669f3..ab7029b42d2 100644
--- a/usr.bin/tmux/cmd-load-buffer.c
+++ b/usr.bin/tmux/cmd-load-buffer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-load-buffer.c,v 1.36 2015/11/10 22:29:33 nicm Exp $ */
+/* $OpenBSD: cmd-load-buffer.c,v 1.37 2015/11/10 22:33:47 nicm Exp $ */
/*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
@@ -81,8 +81,9 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
file = xstrdup(path);
else
xasprintf(&file, "%s/%s", cwd, path);
- if (realpath(file, resolved) == NULL) {
- cmdq_error(cmdq, "%s: %s", file, strerror(errno));
+ if (realpath(file, resolved) == NULL &&
+ strlcpy(resolved, file, sizeof resolved) >= sizeof resolved) {
+ cmdq_error(cmdq, "%s: %s", file, strerror(ENAMETOOLONG));
return (CMD_RETURN_ERROR);
}
f = fopen(resolved, "rb");