Skip to content

Commit

Permalink
fix fuzzing error in ReadContent (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
slipstak2 authored Jan 24, 2024
1 parent 5fb1854 commit 73b30ae
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cloud/filestore/libs/vfs_fuse/fs_impl_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class TDirectoryHandle
return TDirectoryContent{content, 0, size};
}

TMaybe<TDirectoryContent> ReadContent(size_t size, size_t offset)
TMaybe<TDirectoryContent> ReadContent(size_t size, size_t offset, TLog& Log)
{
size_t end = 0;
TBufferPtr content = nullptr;
Expand All @@ -85,8 +85,10 @@ class TDirectoryHandle
TDirectoryContent result;
if (content) {
offset = offset - (end - content->size());
Y_ABORT_UNLESS(offset < content->size(), "off %lu size %lu",
offset, content->size());
if (offset >= content->size()) {
STORAGE_ERROR("off %lu size %lu", offset, content->size());
return Nothing();
}
result = {content, offset, size};
}

Expand Down Expand Up @@ -277,7 +279,7 @@ void TFileSystem::ReadDir(
if (!offset) {
// directory contents need to be refreshed on rewinddir()
handle->ResetContent();
} else if (auto content = handle->ReadContent(size, offset)) {
} else if (auto content = handle->ReadContent(size, offset, Log)) {
reply(*this, *content);
return;
}
Expand Down

0 comments on commit 73b30ae

Please sign in to comment.