|
Lines 58-64
CURLcode Curl_getworkingpath(struct connectdata *conn,
Link Here
|
| 58 |
memcpy(real_path, working_path, 1 + working_path_len); |
58 |
memcpy(real_path, working_path, 1 + working_path_len); |
| 59 |
} |
59 |
} |
| 60 |
else if(conn->handler->protocol & CURLPROTO_SFTP) { |
60 |
else if(conn->handler->protocol & CURLPROTO_SFTP) { |
| 61 |
if((working_path_len > 1) && (working_path[1] == '~')) { |
61 |
if((!strcmp("/~", working_path) || |
|
|
62 |
(working_path_len > 2) && !memcmp(working_path, "/~/", 3))) { |
| 62 |
size_t homelen = strlen(homedir); |
63 |
size_t homelen = strlen(homedir); |
| 63 |
real_path = malloc(homelen + working_path_len + 1); |
64 |
real_path = malloc(homelen + working_path_len + 1); |
| 64 |
if(real_path == NULL) { |
65 |
if(real_path == NULL) { |
|
Lines 68-78
CURLcode Curl_getworkingpath(struct connectdata *conn,
Link Here
|
| 68 |
/* It is referenced to the home directory, so strip the |
69 |
/* It is referenced to the home directory, so strip the |
| 69 |
leading '/' */ |
70 |
leading '/' */ |
| 70 |
memcpy(real_path, homedir, homelen); |
71 |
memcpy(real_path, homedir, homelen); |
| 71 |
real_path[homelen] = '/'; |
72 |
real_path[homelen] = '\0'; |
| 72 |
real_path[homelen + 1] = '\0'; |
73 |
if(working_path_len > 2) { |
| 73 |
if(working_path_len > 3) { |
74 |
int copyfrom = 3; |
| 74 |
memcpy(real_path + homelen + 1, working_path + 3, |
75 |
/* Copy a separating '/' if homedir does not end with one */ |
| 75 |
1 + working_path_len -3); |
76 |
if(homelen && (homedir[homelen-1] != '/')) |
|
|
77 |
copyfrom = 2; |
| 78 |
memcpy(real_path+homelen, working_path + copyfrom, |
| 79 |
1 + working_path_len - copyfrom); |
| 76 |
} |
80 |
} |
| 77 |
} |
81 |
} |
| 78 |
else { |
82 |
else { |