=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/cmd-load-buffer.c,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- src/usr.bin/tmux/cmd-load-buffer.c 2013/10/10 12:00:21 1.24 +++ src/usr.bin/tmux/cmd-load-buffer.c 2013/10/10 12:26:35 1.25 @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-load-buffer.c,v 1.24 2013/10/10 12:00:21 nicm Exp $ */ +/* $OpenBSD: cmd-load-buffer.c,v 1.25 2013/10/10 12:26:35 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -49,11 +50,11 @@ struct client *c = cmdq->client; struct session *s; FILE *f; - const char *path, *newpath, *wd; + const char *path; char *pdata, *new_pdata, *cause; size_t psize; u_int limit; - int ch, error, buffer, *buffer_ptr; + int ch, error, buffer, *buffer_ptr, cwd, fd; if (!args_has(args, 'b')) buffer = -1; @@ -81,20 +82,17 @@ return (CMD_RETURN_WAIT); } - if (c != NULL) - wd = c->cwd; - else if ((s = cmd_current_session(cmdq, 0)) != NULL) { - wd = options_get_string(&s->options, "default-path"); - if (*wd == '\0') - wd = s->cwd; - } else - wd = NULL; - if (wd != NULL && *wd != '\0') { - newpath = get_full_path(wd, path); - if (newpath != NULL) - path = newpath; - } - if ((f = fopen(path, "rb")) == NULL) { + if (c != NULL && c->session == NULL) + cwd = c->cwd; + else if ((s = cmd_current_session(cmdq, 0)) != NULL) + cwd = s->cwd; + else + cwd = AT_FDCWD; + + if ((fd = openat(cwd, path, O_RDONLY)) == -1 || + (f = fdopen(fd, "rb")) == NULL) { + if (fd != -1) + close(fd); cmdq_error(cmdq, "%s: %s", path, strerror(errno)); return (CMD_RETURN_ERROR); }