diff options
author | Thomas Adam <thomas@xteddy.org> | 2015-11-11 08:14:36 +0000 |
---|---|---|
committer | Thomas Adam <thomas@xteddy.org> | 2015-11-11 08:14:36 +0000 |
commit | 35fd6d134a84cda69730310c89846f2bacb3cfbd (patch) | |
tree | d19140d154d7149f3982e62ea77dcbcb776a4965 /cmd-save-buffer.c | |
parent | 896581628dc53556861b63f2cb4094a48f9eaf94 (diff) | |
parent | 6f3475c6c713245f5ec760298af9a04b8465b844 (diff) | |
download | rtmux-35fd6d134a84cda69730310c89846f2bacb3cfbd.tar.gz rtmux-35fd6d134a84cda69730310c89846f2bacb3cfbd.tar.bz2 rtmux-35fd6d134a84cda69730310c89846f2bacb3cfbd.zip |
Merge branch 'obsd-master'
Conflicts:
utf8.c
Diffstat (limited to 'cmd-save-buffer.c')
-rw-r--r-- | cmd-save-buffer.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/cmd-save-buffer.c b/cmd-save-buffer.c index 6c55fabb..87afe7ee 100644 --- a/cmd-save-buffer.c +++ b/cmd-save-buffer.c @@ -102,11 +102,16 @@ cmd_save_buffer_exec(struct cmd *self, struct cmd_q *cmdq) if (args_has(self->args, 'a')) flags = "ab"; - xasprintf(&file, "%s/%s", cwd, path); - if (realpath(file, resolved) == NULL) - f = NULL; + if (*path == '/') + file = xstrdup(path); else - f = fopen(resolved, flags); + 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, flags); free(file); if (f == NULL) { cmdq_error(cmdq, "%s: %s", resolved, strerror(errno)); |