Fix ASAN failure with backupable DB

Summary: It looks like ASAN with gcc 4.9 works better than 4.8.1. It detected this possibility of heap buffer overflow. This was in our codebase for a year :)

Test Plan: COMPILE_WITH_ASAN=1 make backupable_db && ./backupable_db

Reviewers: yhchiang, rven, sdong

Reviewed By: sdong

Subscribers: dhruba, leveldb

Differential Revision: https://reviews.facebook.net/D32085
main
Igor Canadi 10 years ago
parent 910186c278
commit a52dd00243
  1. 3
      utilities/backupable/backupable_db.cc

@ -1207,8 +1207,7 @@ Status BackupEngineImpl::BackupMeta::LoadFromFile(
line.remove_prefix(checksum_prefix.size());
checksum_value = static_cast<uint32_t>(
strtoul(line.data(), nullptr, 10));
if (memcmp(line.data(), std::to_string(checksum_value).c_str(),
line.size() - 1) != 0) {
if (line != std::to_string(checksum_value)) {
return Status::Corruption("Invalid checksum value");
}
} else {

Loading…
Cancel
Save