提交 86294613 编写于 作者: J jy0 提交者: LINGuanRen

primary_zone length overflow when memcpy

上级 d10ad3a0
......@@ -41,17 +41,22 @@ int ObPrimaryZoneUtil::init(const common::ObIArray<common::ObString>& zone_list)
LOG_WARN("invalid argument", K(ret), K(primary_zone_), "zone list count", zone_list.count(), KP(zone_region_list_));
} else {
int64_t len = strlen(primary_zone_.ptr());
MEMCPY(primary_zone_str_, primary_zone_.ptr(), len);
primary_zone_str_[len] = '\0';
common::ObZone zone;
for (int64_t i = 0; OB_SUCC(ret) && i < zone_list.count(); ++i) {
zone.reset();
if (OB_FAIL(zone.assign(zone_list.at(i).ptr()))) {
LOG_WARN("fail to assign zone", K(ret));
} else if (OB_FAIL(zone_list_.push_back(zone))) {
LOG_WARN("fail to push back", K(ret));
} else {
} // no more to do
if (common::MAX_ZONE_LENGTH < len) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("primary_zone length overflowed", KR(ret), K(len), "max_zone_length", MAX_ZONE_LENGTH);
} else {
MEMCPY(primary_zone_str_, primary_zone_.ptr(), len);
primary_zone_str_[len] = '\0';
common::ObZone zone;
for (int64_t i = 0; OB_SUCC(ret) && i < zone_list.count(); ++i) {
zone.reset();
if (OB_FAIL(zone.assign(zone_list.at(i).ptr()))) {
LOG_WARN("fail to assign zone", K(ret));
} else if (OB_FAIL(zone_list_.push_back(zone))) {
LOG_WARN("fail to push back", K(ret));
} else {
} // no more to do
}
}
if (OB_SUCC(ret)) {
is_inited_ = true;
......@@ -73,13 +78,18 @@ int ObPrimaryZoneUtil::init(const common::ObIArray<common::ObZone>& zone_list)
LOG_WARN("invalid argument", K(ret), K(primary_zone_), "zone list count", zone_list.count(), KP(zone_region_list_));
} else {
int64_t len = strlen(primary_zone_.ptr());
MEMCPY(primary_zone_str_, primary_zone_.ptr(), len);
primary_zone_str_[len] = '\0';
for (int64_t i = 0; OB_SUCC(ret) && i < zone_list.count(); ++i) {
if (OB_FAIL(zone_list_.push_back(zone_list.at(i)))) {
LOG_WARN("fail to push back", K(ret));
} else {
} // no more to do
if (common::MAX_ZONE_LENGTH < len) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("primary_zone length overflowed", KR(ret), K(len), "max_zone_length", MAX_ZONE_LENGTH);
} else {
MEMCPY(primary_zone_str_, primary_zone_.ptr(), len);
primary_zone_str_[len] = '\0';
for (int64_t i = 0; OB_SUCC(ret) && i < zone_list.count(); ++i) {
if (OB_FAIL(zone_list_.push_back(zone_list.at(i)))) {
LOG_WARN("fail to push back", K(ret));
} else {
} // no more to do
}
}
if (OB_SUCC(ret)) {
is_inited_ = true;
......@@ -100,9 +110,14 @@ int ObPrimaryZoneUtil::init()
LOG_WARN("invalid argument", K(ret), K(primary_zone_), KP(zone_region_list_));
} else {
int64_t len = strlen(primary_zone_.ptr());
MEMCPY(primary_zone_str_, primary_zone_.ptr(), len);
primary_zone_str_[len] = '\0';
is_inited_ = true;
if (common::MAX_ZONE_LENGTH < len) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("primary_zone length overflowed", KR(ret), K(len), "max_zone_length", MAX_ZONE_LENGTH);
} else {
MEMCPY(primary_zone_str_, primary_zone_.ptr(), len);
primary_zone_str_[len] = '\0';
is_inited_ = true;
}
}
return ret;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册