summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2015-11-10 22:33:48 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2015-11-10 22:33:48 +0000
commit587ae9cc9aae8e7228a117a026ce40d68bbcfd42 (patch)
tree4927b38882e0b7b6144a6e4e735861d8f71a9ab7
parent202ae6648f03f943d96f2cd8416448ede0efdb9d (diff)
If realpath() fails just try the original path.
-rw-r--r--usr.bin/tmux/cmd-load-buffer.c7
-rw-r--r--usr.bin/tmux/cmd-save-buffer.c7
2 files changed, 8 insertions, 6 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");
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);