diff options
author | 2015-11-10 22:33:47 +0000 | |
---|---|---|
committer | 2015-11-10 22:33:47 +0000 | |
commit | f1973d0b44668e2058f3bfc60b30305aadac1a50 (patch) | |
tree | 3f6fbadc765c137dff3888e3994cd73021a2272f /usr.bin/tmux/cmd-save-buffer.c | |
parent | Handle absolute paths properly, and don't use resolved path in (diff) | |
download | wireguard-openbsd-f1973d0b44668e2058f3bfc60b30305aadac1a50.tar.xz wireguard-openbsd-f1973d0b44668e2058f3bfc60b30305aadac1a50.zip |
If realpath() fails just try the original path.
Diffstat (limited to 'usr.bin/tmux/cmd-save-buffer.c')
-rw-r--r-- | usr.bin/tmux/cmd-save-buffer.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/usr.bin/tmux/cmd-save-buffer.c b/usr.bin/tmux/cmd-save-buffer.c index f61fb92f61c..931840367ee 100644 --- a/usr.bin/tmux/cmd-save-buffer.c +++ b/usr.bin/tmux/cmd-save-buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-save-buffer.c,v 1.32 2015/11/10 22:29:33 nicm Exp $ */ +/* $OpenBSD: cmd-save-buffer.c,v 1.33 2015/11/10 22:33:47 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org> @@ -107,8 +107,9 @@ cmd_save_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, flags); |