Remove stoull_full() from etcd_state_client.cpp

rel-0.5
Vitaliy Filippov 2021-03-31 01:18:28 +03:00
parent 3e162d95a0
commit 688821665a
1 changed files with 11 additions and 6 deletions

View File

@ -336,8 +336,10 @@ void etcd_state_client_t::parse_state(const std::string & key, const json11::Jso
{ {
pool_config_t pc; pool_config_t pc;
// ID // ID
pool_id_t pool_id = stoull_full(pool_item.first); pool_id_t pool_id;
if (!pool_id || pool_id >= POOL_ID_MAX) char null_byte = 0;
sscanf(pool_item.first.c_str(), "%u%c", &pool_id, &null_byte);
if (!pool_id || pool_id >= POOL_ID_MAX || null_byte != 0)
{ {
printf("Pool ID %s is invalid (must be a number less than 0x%x), skipping pool\n", pool_item.first.c_str(), POOL_ID_MAX); printf("Pool ID %s is invalid (must be a number less than 0x%x), skipping pool\n", pool_item.first.c_str(), POOL_ID_MAX);
continue; continue;
@ -449,16 +451,19 @@ void etcd_state_client_t::parse_state(const std::string & key, const json11::Jso
} }
for (auto & pool_item: value["items"].object_items()) for (auto & pool_item: value["items"].object_items())
{ {
pool_id_t pool_id = stoull_full(pool_item.first); pool_id_t pool_id;
if (!pool_id || pool_id >= POOL_ID_MAX) char null_byte = 0;
sscanf(pool_item.first.c_str(), "%u%c", &pool_id, &null_byte);
if (!pool_id || pool_id >= POOL_ID_MAX || null_byte != 0)
{ {
printf("Pool ID %s is invalid in PG configuration (must be a number less than 0x%x), skipping pool\n", pool_item.first.c_str(), POOL_ID_MAX); printf("Pool ID %s is invalid in PG configuration (must be a number less than 0x%x), skipping pool\n", pool_item.first.c_str(), POOL_ID_MAX);
continue; continue;
} }
for (auto & pg_item: pool_item.second.object_items()) for (auto & pg_item: pool_item.second.object_items())
{ {
pg_num_t pg_num = stoull_full(pg_item.first); pg_num_t pg_num = 0;
if (!pg_num) sscanf(pg_item.first.c_str(), "%u%c", &pg_num, &null_byte);
if (!pg_num || null_byte != 0)
{ {
printf("Bad key in pool %u PG configuration: %s (must be a number), skipped\n", pool_id, pg_item.first.c_str()); printf("Bad key in pool %u PG configuration: %s (must be a number), skipped\n", pool_id, pg_item.first.c_str());
continue; continue;