aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libssh/sftp.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/libssh/sftp.c b/libssh/sftp.c
index f737958e..64d1aa66 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 */