CVE-2012-4559: Make sure we don't free name and longname twice on error.
Этот коммит содержится в:
родитель
68d04c8e47
Коммит
571dc42335
26
src/sftp.c
26
src/sftp.c
@ -1165,8 +1165,8 @@ static char *sftp_parse_longname(const char *longname,
|
|||||||
so that number of pairs equals extended_count */
|
so that number of pairs equals extended_count */
|
||||||
static sftp_attributes sftp_parse_attr_3(sftp_session sftp, ssh_buffer buf,
|
static sftp_attributes sftp_parse_attr_3(sftp_session sftp, ssh_buffer buf,
|
||||||
int expectname) {
|
int expectname) {
|
||||||
ssh_string longname = NULL;
|
ssh_string longname;
|
||||||
ssh_string name = NULL;
|
ssh_string name;
|
||||||
sftp_attributes attr;
|
sftp_attributes attr;
|
||||||
uint32_t flags = 0;
|
uint32_t flags = 0;
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
@ -1181,19 +1181,27 @@ static sftp_attributes sftp_parse_attr_3(sftp_session sftp, ssh_buffer buf,
|
|||||||
/* This isn't really a loop, but it is like a try..catch.. */
|
/* This isn't really a loop, but it is like a try..catch.. */
|
||||||
do {
|
do {
|
||||||
if (expectname) {
|
if (expectname) {
|
||||||
if ((name = buffer_get_ssh_string(buf)) == NULL ||
|
name = buffer_get_ssh_string(buf);
|
||||||
(attr->name = ssh_string_to_char(name)) == NULL) {
|
if (name == NULL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
attr->name = ssh_string_to_char(name);
|
||||||
ssh_string_free(name);
|
ssh_string_free(name);
|
||||||
|
if (attr->name == NULL) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
ssh_log(sftp->session, SSH_LOG_RARE, "Name: %s", attr->name);
|
ssh_log(sftp->session, SSH_LOG_RARE, "Name: %s", attr->name);
|
||||||
|
|
||||||
if ((longname=buffer_get_ssh_string(buf)) == NULL ||
|
longname = buffer_get_ssh_string(buf);
|
||||||
(attr->longname=ssh_string_to_char(longname)) == NULL) {
|
if (longname == NULL) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
attr->longname = ssh_string_to_char(longname);
|
||||||
|
ssh_string_free(longname);
|
||||||
|
if (attr->longname == NULL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ssh_string_free(longname);
|
|
||||||
|
|
||||||
/* Set owner and group if we talk to openssh and have the longname */
|
/* Set owner and group if we talk to openssh and have the longname */
|
||||||
if (ssh_get_openssh_version(sftp->session)) {
|
if (ssh_get_openssh_version(sftp->session)) {
|
||||||
@ -1298,8 +1306,6 @@ static sftp_attributes sftp_parse_attr_3(sftp_session sftp, ssh_buffer buf,
|
|||||||
|
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
/* break issued somewhere */
|
/* break issued somewhere */
|
||||||
ssh_string_free(name);
|
|
||||||
ssh_string_free(longname);
|
|
||||||
ssh_string_free(attr->extended_type);
|
ssh_string_free(attr->extended_type);
|
||||||
ssh_string_free(attr->extended_data);
|
ssh_string_free(attr->extended_data);
|
||||||
SAFE_FREE(attr->name);
|
SAFE_FREE(attr->name);
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user