aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2012-10-08 20:57:49 +0200
committerAndreas Schneider <asn@cryptomilk.org>2012-10-12 08:07:01 +0200
commit188c5968032ffbd1764b631c0c8c3e54f7a3091a (patch)
tree66ea4145aee3556f9d1fd21ca8c9a782d28afcf6
parent02953019283fca8069bb7a3a4a11c7bedd2941fc (diff)
downloadlibssh-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.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/sftp.c b/src/sftp.c
index 835588e2..0a90e662 100644
--- a/src/sftp.c
+++ b/src/sftp.c
@@ -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);