aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <mail@cynapses.org>2010-03-02 14:15:20 +0100
committerAndreas Schneider <mail@cynapses.org>2010-03-02 14:15:20 +0100
commit8424c7a7473c6c371cdce847e5306353366ed67f (patch)
tree3cc493aa18fc43b1c53eb28dfc625a9c559638f8
parent464176d5111676161d809ac3f5aeaa0f9fb2ff5b (diff)
downloadlibssh-8424c7a7473c6c371cdce847e5306353366ed67f.tar.gz
libssh-8424c7a7473c6c371cdce847e5306353366ed67f.tar.xz
libssh-8424c7a7473c6c371cdce847e5306353366ed67f.zip
Fixed sftp_parse_longname() on Windows.
There is no strndup function on Windows.
-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 */