=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/sftp.c,v retrieving revision 1.138 retrieving revision 1.139 diff -u -r1.138 -r1.139 --- src/usr.bin/ssh/sftp.c 2012/09/18 10:36:12 1.138 +++ src/usr.bin/ssh/sftp.c 2012/09/21 10:53:07 1.139 @@ -1,4 +1,4 @@ -/* $OpenBSD: sftp.c,v 1.138 2012/09/18 10:36:12 dtucker Exp $ */ +/* $OpenBSD: sftp.c,v 1.139 2012/09/21 10:53:07 dtucker Exp $ */ /* * Copyright (c) 2001-2004 Damien Miller * @@ -1675,7 +1675,7 @@ { glob_t g; char *tmp, *tmp2, ins[3]; - u_int i, hadglob, pwdlen, len, tmplen, filelen; + u_int i, hadglob, pwdlen, len, tmplen, filelen, isabs; const LineInfo *lf; /* Glob from "file" location */ @@ -1684,6 +1684,9 @@ else xasprintf(&tmp, "%s*", file); + /* Check if the path is absolute. */ + isabs = tmp[0] == '/'; + memset(&g, 0, sizeof(g)); if (remote != LOCAL) { tmp = make_absolute(tmp, remote_path); @@ -1718,7 +1721,7 @@ goto out; tmp2 = complete_ambiguous(file, g.gl_pathv, g.gl_matchc); - tmp = path_strip(tmp2, remote_path); + tmp = path_strip(tmp2, isabs ? NULL : remote_path); xfree(tmp2); if (tmp == NULL)