primary_zone length overflow when memcpy
This commit is contained in:
@ -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_));
|
LOG_WARN("invalid argument", K(ret), K(primary_zone_), "zone list count", zone_list.count(), KP(zone_region_list_));
|
||||||
} else {
|
} else {
|
||||||
int64_t len = strlen(primary_zone_.ptr());
|
int64_t len = strlen(primary_zone_.ptr());
|
||||||
MEMCPY(primary_zone_str_, primary_zone_.ptr(), len);
|
if (common::MAX_ZONE_LENGTH < len) {
|
||||||
primary_zone_str_[len] = '\0';
|
ret = OB_ERR_UNEXPECTED;
|
||||||
common::ObZone zone;
|
LOG_WARN("primary_zone length overflowed", KR(ret), K(len), "max_zone_length", MAX_ZONE_LENGTH);
|
||||||
for (int64_t i = 0; OB_SUCC(ret) && i < zone_list.count(); ++i) {
|
} else {
|
||||||
zone.reset();
|
MEMCPY(primary_zone_str_, primary_zone_.ptr(), len);
|
||||||
if (OB_FAIL(zone.assign(zone_list.at(i).ptr()))) {
|
primary_zone_str_[len] = '\0';
|
||||||
LOG_WARN("fail to assign zone", K(ret));
|
common::ObZone zone;
|
||||||
} else if (OB_FAIL(zone_list_.push_back(zone))) {
|
for (int64_t i = 0; OB_SUCC(ret) && i < zone_list.count(); ++i) {
|
||||||
LOG_WARN("fail to push back", K(ret));
|
zone.reset();
|
||||||
} else {
|
if (OB_FAIL(zone.assign(zone_list.at(i).ptr()))) {
|
||||||
} // no more to do
|
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)) {
|
if (OB_SUCC(ret)) {
|
||||||
is_inited_ = true;
|
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_));
|
LOG_WARN("invalid argument", K(ret), K(primary_zone_), "zone list count", zone_list.count(), KP(zone_region_list_));
|
||||||
} else {
|
} else {
|
||||||
int64_t len = strlen(primary_zone_.ptr());
|
int64_t len = strlen(primary_zone_.ptr());
|
||||||
MEMCPY(primary_zone_str_, primary_zone_.ptr(), len);
|
if (common::MAX_ZONE_LENGTH < len) {
|
||||||
primary_zone_str_[len] = '\0';
|
ret = OB_ERR_UNEXPECTED;
|
||||||
for (int64_t i = 0; OB_SUCC(ret) && i < zone_list.count(); ++i) {
|
LOG_WARN("primary_zone length overflowed", KR(ret), K(len), "max_zone_length", MAX_ZONE_LENGTH);
|
||||||
if (OB_FAIL(zone_list_.push_back(zone_list.at(i)))) {
|
} else {
|
||||||
LOG_WARN("fail to push back", K(ret));
|
MEMCPY(primary_zone_str_, primary_zone_.ptr(), len);
|
||||||
} else {
|
primary_zone_str_[len] = '\0';
|
||||||
} // no more to do
|
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)) {
|
if (OB_SUCC(ret)) {
|
||||||
is_inited_ = true;
|
is_inited_ = true;
|
||||||
@ -100,9 +110,14 @@ int ObPrimaryZoneUtil::init()
|
|||||||
LOG_WARN("invalid argument", K(ret), K(primary_zone_), KP(zone_region_list_));
|
LOG_WARN("invalid argument", K(ret), K(primary_zone_), KP(zone_region_list_));
|
||||||
} else {
|
} else {
|
||||||
int64_t len = strlen(primary_zone_.ptr());
|
int64_t len = strlen(primary_zone_.ptr());
|
||||||
MEMCPY(primary_zone_str_, primary_zone_.ptr(), len);
|
if (common::MAX_ZONE_LENGTH < len) {
|
||||||
primary_zone_str_[len] = '\0';
|
ret = OB_ERR_UNEXPECTED;
|
||||||
is_inited_ = true;
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user