Skip to content

Commit

Permalink
fs: fix parsing of end records
Browse files Browse the repository at this point in the history
End records have no data, just a type, so don't try to read anything
beyond the type.

Signed-off-by: Hans Holmberg <[email protected]>
  • Loading branch information
yhr committed Apr 30, 2021
1 parent 1b2f42c commit 76101d1
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions fs/fs_zenfs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -751,8 +751,11 @@ Status ZenFS::RecoverFrom(ZenMetaLog* log) {

if (!GetFixed32(&record, &tag)) break;

if (!GetLengthPrefixedSlice(&record, &data))
if (tag == kEndRecord) break;

if (!GetLengthPrefixedSlice(&record, &data)) {
return Status::Corruption("ZenFS", "No recovery record data");
}

switch (tag) {
case kCompleteFilesSnapshot:
Expand Down Expand Up @@ -784,10 +787,6 @@ Status ZenFS::RecoverFrom(ZenMetaLog* log) {
}
break;

case kEndRecord:
done = true;
break;

default:
Warn(logger_, "Unexpected metadata record tag: %u", tag);
return Status::Corruption("ZenFS", "Unexpected tag");
Expand Down

0 comments on commit 76101d1

Please sign in to comment.