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

primary_zone length overflow when memcpy

上级 d10ad3a0
......@@ -41,6 +41,10 @@ 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());
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;
......@@ -53,6 +57,7 @@ int ObPrimaryZoneUtil::init(const common::ObIArray<common::ObString>& zone_list)
} else {
} // no more to do
}
}
if (OB_SUCC(ret)) {
is_inited_ = true;
}
......@@ -73,6 +78,10 @@ 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());
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) {
......@@ -81,6 +90,7 @@ int ObPrimaryZoneUtil::init(const common::ObIArray<common::ObZone>& zone_list)
} else {
} // no more to do
}
}
if (OB_SUCC(ret)) {
is_inited_ = true;
}
......@@ -100,10 +110,15 @@ int ObPrimaryZoneUtil::init()
LOG_WARN("invalid argument", K(ret), K(primary_zone_), KP(zone_region_list_));
} else {
int64_t len = strlen(primary_zone_.ptr());
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.
先完成此消息的编辑!
想要评论请 注册