mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-12-02 01:17:52 +03:00
sftp: Use strndup()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
12
src/sftp.c
12
src/sftp.c
@@ -1146,7 +1146,6 @@ static char *sftp_parse_longname(const char *longname,
|
||||
enum sftp_longname_field_e longname_field) {
|
||||
const char *p, *q;
|
||||
size_t len, field = 0;
|
||||
char *x;
|
||||
|
||||
p = longname;
|
||||
/* Find the beginning of the field which is specified by sftp_longanme_field_e. */
|
||||
@@ -1167,16 +1166,9 @@ static char *sftp_parse_longname(const char *longname,
|
||||
q++;
|
||||
}
|
||||
|
||||
/* There is no strndup on windows */
|
||||
len = q - p + 1;
|
||||
x = calloc(1, len);
|
||||
if (x == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
len = q - p;
|
||||
|
||||
snprintf(x, len, "%s", p);
|
||||
|
||||
return x;
|
||||
return strndup(p, len);
|
||||
}
|
||||
|
||||
/* sftp version 0-3 code. It is different from the v4 */
|
||||
|
||||
Reference in New Issue
Block a user