primary_zone length overflow when memcpy
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user