Fix path resolution

This commit is contained in:
Andrew Pamment 2017-04-05 10:35:23 +10:00
parent ed85c78e69
commit 3dad6c5080

View File

@ -98,8 +98,16 @@ static void parse_path(struct ftpclient *client, char *path, char **result) {
newpath[0] = '\0'; newpath[0] = '\0';
pptr = proot; pptr = proot;
int i = 0;
while (pptr != NULL && pptr->data != NULL) { 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; pptr = pptr->next;
} }