aboutsummaryrefslogtreecommitdiff
path: root/cmd-load-buffer.c
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2015-11-11 08:14:36 +0000
committerThomas Adam <thomas@xteddy.org>2015-11-11 08:14:36 +0000
commit35fd6d134a84cda69730310c89846f2bacb3cfbd (patch)
treed19140d154d7149f3982e62ea77dcbcb776a4965 /cmd-load-buffer.c
parent896581628dc53556861b63f2cb4094a48f9eaf94 (diff)
parent6f3475c6c713245f5ec760298af9a04b8465b844 (diff)
downloadrtmux-35fd6d134a84cda69730310c89846f2bacb3cfbd.tar.gz
rtmux-35fd6d134a84cda69730310c89846f2bacb3cfbd.tar.bz2
rtmux-35fd6d134a84cda69730310c89846f2bacb3cfbd.zip
Merge branch 'obsd-master'
Conflicts: utf8.c
Diffstat (limited to 'cmd-load-buffer.c')
-rw-r--r--cmd-load-buffer.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/cmd-load-buffer.c b/cmd-load-buffer.c
index c55e6c11..9352cbe5 100644
--- a/cmd-load-buffer.c
+++ b/cmd-load-buffer.c
@@ -77,11 +77,16 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
else
cwd = ".";
- xasprintf(&file, "%s/%s", cwd, path);
- if (realpath(file, resolved) == NULL)
- f = NULL;
+ if (*path == '/')
+ file = xstrdup(path);
else
- f = fopen(resolved, "rb");
+ xasprintf(&file, "%s/%s", cwd, path);
+ 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");
free(file);
if (f == NULL) {
cmdq_error(cmdq, "%s: %s", resolved, strerror(errno));