diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2012-10-08 20:57:49 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2012-10-12 08:07:01 +0200 |
commit | 188c5968032ffbd1764b631c0c8c3e54f7a3091a (patch) | |
tree | 66ea4145aee3556f9d1fd21ca8c9a782d28afcf6 | |
parent | 02953019283fca8069bb7a3a4a11c7bedd2941fc (diff) | |
download | libssh-188c5968032ffbd1764b631c0c8c3e54f7a3091a.tar.gz libssh-188c5968032ffbd1764b631c0c8c3e54f7a3091a.tar.xz libssh-188c5968032ffbd1764b631c0c8c3e54f7a3091a.zip |
sftp: Don't leak owner and group in sftp_parse_attr_4.
-rw-r--r-- | src/sftp.c | 21 |
1 files changed, 15 insertions, 6 deletions
@@ -966,12 +966,23 @@ static sftp_attributes sftp_parse_attr_4(sftp_session sftp, ssh_buffer buf, } if (flags & SSH_FILEXFER_ATTR_OWNERGROUP) { - if((owner = buffer_get_ssh_string(buf)) == NULL || - (attr->owner = ssh_string_to_char(owner)) == NULL) { + owner = buffer_get_ssh_string(buf); + if (owner == NULL) { break; } - if ((group = buffer_get_ssh_string(buf)) == NULL || - (attr->group = ssh_string_to_char(group)) == NULL) { + attr->owner = ssh_string_to_char(owner); + string_free(owner); + if (attr->owner == NULL) { + break; + } + + group = buffer_get_ssh_string(buf); + if (group == NULL) { + break; + } + attr->group = ssh_string_to_char(group); + string_free(group); + if (attr->group == NULL) { break; } } @@ -1074,8 +1085,6 @@ static sftp_attributes sftp_parse_attr_4(sftp_session sftp, ssh_buffer buf, if (ok == 0) { /* break issued somewhere */ - ssh_string_free(owner); - ssh_string_free(group); ssh_string_free(attr->acl); ssh_string_free(attr->extended_type); ssh_string_free(attr->extended_data); |