From a32e6c7bb4d15ec403efd3e3a9ca5967611bf8d1 Mon Sep 17 00:00:00 2001 From: Patrick LeBlanc Date: Thu, 23 May 2019 13:41:24 -0500 Subject: [PATCH] Fixed a possible size mismatch in Sync, which could be caused by a truncated logical file. --- src/Synchronizer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Synchronizer.cpp b/src/Synchronizer.cpp index cbe402956..ce1d3a3e2 100644 --- a/src/Synchronizer.cpp +++ b/src/Synchronizer.cpp @@ -340,7 +340,7 @@ void Synchronizer::synchronizeDelete(const string &sourceFile, list::ite ScopedWriteLock s(ioc, sourceFile); cs->deleteObject(*it); - // delete any pending jobs for *it. + // delete any pending jobs for *it. There shouldn't be any, this is out of pure paranoia. boost::unique_lock sc(mutex); pendingOps.erase(*it); } @@ -414,17 +414,17 @@ void Synchronizer::synchronizeWithJournal(const string &sourceFile, list } throw runtime_error(string("Synchronizer: getObject() failed: ") + strerror_r(errno, buf, 80)); } - assert(size <= mdEntry.length); + //TODO!! This sucks. Need a way to pass in a larger array to cloud storage, and also have it not // do any add'l alloc'ing or copying if (size < mdEntry.length) { boost::shared_array tmp(new uint8_t[mdEntry.length]()); memcpy(tmp.get(), data.get(), size); - memset(&tmp[size], 0, mdEntry.length - size); // prob not necessary outside of testing + memset(&tmp[size], 0, mdEntry.length - size); data.swap(tmp); - size = mdEntry.length; } + size = mdEntry.length; // reset length. Using the metadata as a source of truth (truncation), not actual file length. err = ioc->mergeJournalInMem(data, size, journalName.c_str()); if (err)