1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-24 00:58:48 -05:00

scp: fix directory name length used in memcpy

Fix read off end of array due to bad pointer math in getworkingpath for
SCP home directory case.

Closes #4258
This commit is contained in:
Kyle Abramowitz 2019-08-22 20:58:26 +00:00 committed by Daniel Stenberg
parent 65fda739ee
commit 25f9621935
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -55,7 +55,7 @@ CURLcode Curl_getworkingpath(struct connectdata *conn,
}
if((working_path_len > 3) && (!memcmp(working_path, "/~/", 3)))
/* It is referenced to the home directory, so strip the leading '/~/' */
memcpy(real_path, working_path + 3, 4 + working_path_len-3);
memcpy(real_path, working_path + 3, working_path_len - 2);
else
memcpy(real_path, working_path, 1 + working_path_len);
}