Fixed-length strings read past the end of their field
Maintainer thường phản hồi trong vòng 1 ngày
@mattjala đang làm issue này rồi.
Từ ngày 13/10/2026.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
A fixed-length string only carries a terminator when its field is longer than the text it
holds. The HDF5 JNI reads these strings by handing the raw element address to
NewStringUTF, which reads until it finds a terminator, so a string that fills its field
runs on into whatever follows it. HDFView displays those neighbouring bytes as part of the
value wherever it reads the string through H5DreadVL.
The data is already wrong when it crosses the JNI boundary, so HDFView cannot fix the
values. It can detect the condition, which is covered at the end.
Root cause
java/src-jni/jni/h5util.c in the HDF5 source, the H5T_STRING case of
translate_atomic_rbuf:
else {
if (NULL == (jobj = ENVPTR->NewStringUTF(ENVONLY, char_buf))) {
char_buf points at the element. Nothing bounds the read to the element's size. The
variable-length branch just above it is fine, because those strings are always terminated.
Worth noting that H5Dread_string in the same source tree already handles this correctly
for the same kind of field, by copying out the element's own bytes and terminating the
copy itself.
For the file PacketTableIssue.h5 at /rec/Events, where each member is a variable-length
sequence of one byte strings. h5dump shows ("I","n","i","t",...):
before: [Initialize, nitialize, itialize, tialize, ialize, alize, lize, ize, ze]
after: [I, n, i, t, i, a, l, i, z]
It also crosses member boundaries. A compound of {tag: 2 byte string, id: int, note: 4 byte string} with tag holding exactly ab and id given printable bytes:
before: [abAAAAxy, 1094795585, xy]
after: [ab, 1094795585, xy]
The two byte tag swallowed the int member and the string member after it. note is
unaffected because it is shorter than its field, so its padding still terminates it.
Origin
This is not a regression in HDFView. The unbounded read is present unchanged at the hdf5_2.0.0 release tag, which is what HDFView 3.4.1 shipped against, and on current develop.
Likely fix in HDF5
Copy at most the element's own bytes into a buffer, terminate the copy, and convert that,
which is what H5Dread_string already does.
Note that a Java side workaround would only correct the displayed value. The out of bounds
read itself happens in native code and can only be fixed there.
Affected HDFView test files
The defect only reaches HDFView through H5DreadVL, which in practice means a fixed-length
string sitting inside a variable-length type.
A fixed-length string that holds no
variable-length data is read with plain H5Dread into a byte array and converted by
Dataset.byteToString, which takes exactly the field's bytes with
new String(bytes, i * length, length) and trims at the first terminator. That is bounded,
so the library's unbounded read is never reached.
object/src/test/java/object/TestNestedDatatypeShapes.testVlenOfFixedString is already disabled and waiting for a JNI fix.
testArrayOfFixedString beside it is unaffected, because an array of fixed-length strings
contains no variable-length data and takes the flat path.
Next Steps for HDFView
The condition is detectable from the datatype, so HDFView can avoid rendering potentially incorrect values until a fix gets into the JNI itself. Once a JNI patch gets in, this can be removed.
- Ngôn ngữ chính
- Java
- Star
- 157
- Fork
- 28
- Merge trung bình
- 16 giờ 22 phút
- Pull request đã merge (30 ngày)
- 12
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của HDFGroup/hdfview
-
Crash when displaying struct member informationCó thể đã có người làm @mattjala đã nhận 2 ngày trước. Đang mởComponent - HDFView
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 30/100
HDFGroup/hdfview#516 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
User's Guide can't be opened from Help MenuCó thể đã có người làm @mattjala đã nhận 22 ngày trước. Đang mởComponent - HDFView
HDFGroup/hdfview#512 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Component - Build
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Compound members vanish when a variable-length string member is NULLCó thể làm lại được @mattjala đã nhận 30 ngày trước và không có pull request nào đang mở. Đang mởComponent - Object Library
HDFGroup/hdfview#503 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add global vs. user-specific install option in MSICó thể làm lại được @mattjala đã nhận 34 ngày trước và không có pull request nào đang mở. Đang mởComponent - Build
HDFGroup/hdfview#495 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của HDFGroup/hdfview
Issue tương tự
-
bug emitter:client:csharp
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
microsoft/typespec#12572 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
GCC 15.2: -Wcast-qual warning - cast discards const qualifier from pointer target type (H5trace.c)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] RemotingHelper.connect swaps the socket send and receive buffer configurationCó thể đã có người làm @amalsaidov đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-area-label
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 2 ngày
-
area/ai area/backend component/zeebe kind/task
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày