From b4113806e88ed6ee313cbeae56ab55e65ed07268 Mon Sep 17 00:00:00 2001 From: mtheall Date: Tue, 25 Nov 2014 01:24:24 -0600 Subject: [PATCH] fix build_path --- source/ftp.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/source/ftp.c b/source/ftp.c index 26187b1..ebbf1ee 100644 --- a/source/ftp.c +++ b/source/ftp.c @@ -1334,8 +1334,6 @@ static void build_path(ftp_session_t *session, const char *args) { - char *p; - memset(session->buffer, 0, sizeof(session->buffer)); if(args[0] == '/') @@ -1344,14 +1342,12 @@ build_path(ftp_session_t *session, } else { - p = session->cwd + strlen(session->cwd); - while(*--p == '/') - *p = 0; - snprintf(session->buffer, sizeof(session->buffer), "%s/%s", - session->cwd, args); - p = session->buffer + strlen(session->buffer); - while(*--p == '/') - *p = 0; + if(strcmp(session->cwd, "/") == 0) + snprintf(session->buffer, sizeof(session->buffer), "/%s", + args); + else + snprintf(session->buffer, sizeof(session->buffer), "%s/%s", + session->cwd, args); } }