SCP: relative path didn't work

When prefixing a path with /~/ it is supposed to be used relative to the
user's home directory but it didn't work. Now we cut off the entire
three byte sequenct "/~/" which seems to be how OpenSSH does it.

Bug: http://curl.haxx.se/bug/view.cgi?id=1173
Reported by: Balaji Parasuram
This commit is contained in:
Daniel Stenberg 2012-12-21 14:38:33 +01:00
Родитель d738adc1fb
Коммит c30c557e4d
1 изменённых файлов: 3 добавлений и 3 удалений

Просмотреть файл

@ -422,9 +422,9 @@ static CURLcode ssh_getworkingpath(struct connectdata *conn,
free(working_path); free(working_path);
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
} }
if((working_path_len > 1) && (working_path[1] == '~')) if((working_path_len > 3) && (!memcmp(working_path, "/~/", 3)))
/* It is referenced to the home directory, so strip the leading '/' */ /* It is referenced to the home directory, so strip the leading '/~/' */
memcpy(real_path, working_path+1, 1 + working_path_len-1); memcpy(real_path, working_path+3, 4 + working_path_len-3);
else else
memcpy(real_path, working_path, 1 + working_path_len); memcpy(real_path, working_path, 1 + working_path_len);
} }