From 82d4b55685adc1fdb428ccc384d132d945b269e3 Mon Sep 17 00:00:00 2001 From: Jakob Schlyter Date: Tue, 31 Jul 2001 12:42:51 +0000 Subject: avoid paths beginning with "//"; ok markus@ --- usr.bin/ssh/sftp-int.c | 5 +++-- usr.bin/ssh/sftp-server.c | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'usr.bin/ssh') diff --git a/usr.bin/ssh/sftp-int.c b/usr.bin/ssh/sftp-int.c index 77b20f5f691..9fb39f843a4 100644 --- a/usr.bin/ssh/sftp-int.c +++ b/usr.bin/ssh/sftp-int.c @@ -26,7 +26,7 @@ /* XXX: recursive operations */ #include "includes.h" -RCSID("$OpenBSD: sftp-int.c,v 1.38 2001/07/09 07:04:53 deraadt Exp $"); +RCSID("$OpenBSD: sftp-int.c,v 1.39 2001/07/31 12:42:50 jakob Exp $"); #include @@ -206,7 +206,8 @@ path_append(char *p1, char *p2) ret = xmalloc(len); strlcpy(ret, p1, len); - strlcat(ret, "/", len); + if (strcmp(p1, "/") != 0) + strlcat(ret, "/", len); strlcat(ret, p2, len); return(ret); diff --git a/usr.bin/ssh/sftp-server.c b/usr.bin/ssh/sftp-server.c index b8e0f842f31..7f442f86f07 100644 --- a/usr.bin/ssh/sftp-server.c +++ b/usr.bin/ssh/sftp-server.c @@ -22,7 +22,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "includes.h" -RCSID("$OpenBSD: sftp-server.c,v 1.29 2001/06/25 08:25:40 markus Exp $"); +RCSID("$OpenBSD: sftp-server.c,v 1.30 2001/07/31 12:42:50 jakob Exp $"); #include "buffer.h" #include "bufaux.h" @@ -736,8 +736,8 @@ process_readdir(void) stats = xrealloc(stats, nstats * sizeof(Stat)); } /* XXX OVERFLOW ? */ - snprintf(pathname, sizeof pathname, - "%s/%s", path, dp->d_name); + snprintf(pathname, sizeof pathname, "%s%s%s", path, + strcmp(path, "/") ? "/" : "", dp->d_name); if (lstat(pathname, &st) < 0) continue; stat_to_attrib(&st, &(stats[count].attrib)); -- cgit v1.2.3