From a52dd00243ae939ab6dbd1e72c0585ae840066b4 Mon Sep 17 00:00:00 2001 From: Igor Canadi Date: Fri, 23 Jan 2015 15:02:43 -0800 Subject: [PATCH] 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 --- utilities/backupable/backupable_db.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/utilities/backupable/backupable_db.cc b/utilities/backupable/backupable_db.cc index 2a526c940..6338df4c1 100644 --- a/utilities/backupable/backupable_db.cc +++ b/utilities/backupable/backupable_db.cc @@ -1207,8 +1207,7 @@ Status BackupEngineImpl::BackupMeta::LoadFromFile( line.remove_prefix(checksum_prefix.size()); checksum_value = static_cast( 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 {