Merge branch 'obsd-master'

Conflicts:
	utf8.c
This commit is contained in:
Thomas Adam
2015-11-11 08:14:36 +00:00
4 changed files with 322 additions and 163 deletions

View File

@@ -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));