Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix fuzzing error in ReadContent #214

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading