From 8424c7a7473c6c371cdce847e5306353366ed67f Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 2 Mar 2010 14:15:20 +0100 Subject: Fixed sftp_parse_longname() on Windows. There is no strndup function on Windows. --- libssh/sftp.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/libssh/sftp.c b/libssh/sftp.c index f737958..64d1aa6 100644 --- a/libssh/sftp.c +++ b/libssh/sftp.c @@ -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 */ -- cgit