From 3dad6c50809c013a049a4428feaf3c85375f7bf5 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Wed, 5 Apr 2017 10:35:23 +1000 Subject: [PATCH] Fix path resolution --- utils/magiftpd/magiftpd.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/utils/magiftpd/magiftpd.c b/utils/magiftpd/magiftpd.c index 07ed11c..b2e3fb5 100644 --- a/utils/magiftpd/magiftpd.c +++ b/utils/magiftpd/magiftpd.c @@ -98,8 +98,16 @@ static void parse_path(struct ftpclient *client, char *path, char **result) { newpath[0] = '\0'; pptr = proot; + int i = 0; + while (pptr != NULL && pptr->data != NULL) { - snprintf(newpath, PATH_MAX, "%s/%s", newpath, pptr->data); + if (i + strlen(pptr->data) + 2 > PATH_MAX) { + break; + } + newpath[i++] = '/'; + memcpy(&newpath[i], pptr->data, strlen(pptr->data)); + i += strlen(pptr->data); + newpath[i] = '\0'; pptr = pptr->next; }