summaryrefslogtreecommitdiffstats
path: root/cmd-save-buffer.c
diff options
context:
space:
mode:
authornicm <nicm>2015-11-10 22:33:47 +0000
committernicm <nicm>2015-11-10 22:33:47 +0000
commit6f3475c6c713245f5ec760298af9a04b8465b844 (patch)
tree3e5b8b52c57fd4116f503f0392993f6004c6814e /cmd-save-buffer.c
parent005e462e01b58015f3e1d841b185186e6b5d4e14 (diff)
If realpath() fails just try the original path.
Diffstat (limited to 'cmd-save-buffer.c')
-rw-r--r--cmd-save-buffer.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/cmd-save-buffer.c b/cmd-save-buffer.c
index 8de99075..9f3deeda 100644
--- a/cmd-save-buffer.c
+++ b/cmd-save-buffer.c
@@ -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);