Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[Bug] PackedFileReader reads past a slice into the neighbouring file when the offset is beyond the slice size

未关闭 适合新手
#69,863 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
cpp
领域
backend, databases

调研方向

从 issue 中引用的 be/src/io/fs/packed_file_reader.cpp 里的 read_at_impl 计算开始。找到现有的 PackedFileReader 单元测试,并添加对偏移量超出 slice 大小的覆盖,包括打包文件中的相邻 slice。完成标准是:越界读取返回包含 slice 和偏移量详情的 Status::Corruption,有效读取仍能正常工作。

由索引模型根据 Issue 内容生成。

描述

Search before asking
  • I had searched in the issues and found no similar issues.
Version

4.1.4 (cloud mode, packed files). master is the same: be/src/io/fs/packed_file_reader.cpp:54:

size_t max_read = std::min(result.get_size(), static_cast<size_t>(_file_size - offset));
Description

PackedFileReader::read_at_impl reads a slice of a packed file. _file_size is int64_t and offset is size_t, so _file_size - offset is computed in unsigned arithmetic. When offset is past the end of the slice, it wraps to a huge value, max_read becomes the full request size, and the read returns the bytes that follow the slice in the packed file. Those belong to another file, so the caller gets silently wrong data instead of an error (for example, a corrupt-looking index or segment page that is actually a neighbour's bytes).

Solution

Check the offset before computing the length and return Status::Corruption (naming the slice, its size and offset in the packed file) when offset > _file_size (or _file_size < 0); compute the remaining length as static_cast<size_t>(_file_size) - offset.

How to Reproduce?

Unit test: open a PackedFileReader over a slice of size N inside a larger packed file and call read_at(N + k, ...); it returns bytes from the next slice instead of failing.

Anything Else?

An out-of-range offset normally means wrong metadata somewhere upstream of the reader, which is exactly when an error is more useful than another file's bytes.

Are you willing to submit PR?
  • Yes I am willing to submit a PR!
Code of Conduct
主要语言
Java
星标
16.1k
派生
4k
平均合并
1 天 16 小时
30 天内合并 PR
685

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/doris 的其他 Issue

查看 apache/doris 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。