mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-04 12:20:42 +09:00
Fixed sftp_parse_longname() on Windows.
There is no strndup function on Windows.
This commit is contained in:
@@ -1126,7 +1126,8 @@ enum sftp_longname_field_e {
|
||||
static char *sftp_parse_longname(const char *longname,
|
||||
enum sftp_longname_field_e longname_field) {
|
||||
const char *p, *q;
|
||||
size_t field = 0;
|
||||
size_t len, field = 0;
|
||||
char *x;
|
||||
|
||||
p = longname;
|
||||
/* Find the beginning of the field which is specified by sftp_longanme_field_e. */
|
||||
@@ -1147,7 +1148,16 @@ static char *sftp_parse_longname(const char *longname,
|
||||
q++;
|
||||
}
|
||||
|
||||
return strndup(p, q - p);
|
||||
/* There is no strndup on windows */
|
||||
len = q - p + 1;
|
||||
x = malloc(len);
|
||||
if (x == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
snprintf(x, len, "%s", p);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
/* sftp version 0-3 code. It is different from the v4 */
|
||||
|
||||
Reference in New Issue
Block a user