Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở Phù hợp với người mới
#69,863 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
cpp
Lĩnh vực
backend, databases

Hướng nghiên cứu

Bắt đầu với phép tính được trích dẫn trong issue tại be/src/io/fs/packed_file_reader.cpp, ở read_at_impl. Tìm các bài kiểm thử đơn vị PackedFileReader hiện có và bổ sung kiểm thử cho offset vượt quá kích thước slice, bao gồm cả slice liền kề trong tệp được đóng gói. Hoàn thành khi thao tác đọc ngoài phạm vi trả về Status::Corruption kèm thông tin chi tiết về slice và offset, đồng thời các thao tác đọc hợp lệ vẫn hoạt động.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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
Ngôn ngữ chính
Java
Star
16.1k
Fork
4k
Merge trung bình
1 ngày 16 giờ
Pull request đã merge (30 ngày)
685

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của apache/doris

Tất cả issue của apache/doris

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.