peterhuene opened PR #2620 from fix-fd-readdir to main:
Previously,
fd_readdirwas truncating directory entry names based on the
calculation ofmin(name_len, buf_len - bufused), butbufusedwas not being
updated after writing in thedirentstructure to the buffer.This allowed
bufusedto be incremented beyondbuf_lenand returned as the
number of bytes written to the buffer, which is invalid.This fix adjusts
bufusedwhen the buffer is written to for thedirentso
that name truncation happens as expected.Fixes #2618.
peterhuene requested sunfishcode for a review on PR #2620.
peterhuene updated PR #2620 from fix-fd-readdir to main:
Previously,
fd_readdirwas truncating directory entry names based on the
calculation ofmin(name_len, buf_len - bufused), butbufusedwas not being
updated after writing in thedirentstructure to the buffer.This allowed
bufusedto be incremented beyondbuf_lenand returned as the
number of bytes written to the buffer, which is invalid.This fix adjusts
bufusedwhen the buffer is written to for thedirentso
that name truncation happens as expected.Fixes #2618.
peterhuene updated PR #2620 from fix-fd-readdir to main:
Previously,
fd_readdirwas truncating directory entry names based on the
calculation ofmin(name_len, buf_len - bufused), butbufusedwas not being
updated after writing in thedirentstructure to the buffer.This allowed
bufusedto be incremented beyondbuf_lenand returned as the
number of bytes written to the buffer, which is invalid.This fix adjusts
bufusedwhen the buffer is written to for thedirentso
that name truncation happens as expected.Fixes #2618.
peterhuene updated PR #2620 from fix-fd-readdir to main:
Previously,
fd_readdirwas truncating directory entry names based on the
calculation ofmin(name_len, buf_len - bufused), butbufusedwas not being
updated after writing in thedirentstructure to the buffer.This allowed
bufusedto be incremented beyondbuf_lenand returned as the
number of bytes written to the buffer, which is invalid.This fix adjusts
bufusedwhen the buffer is written to for thedirentso
that name truncation happens as expected.Fixes #2618.
pchickey submitted PR Review.
pchickey created PR Review Comment:
the
buf.add(dirent_copy_len)?performs this overflow check, so bufused doesnt have to have a checked add
pchickey submitted PR Review.
pchickey created PR Review Comment:
same here, no need to check the add
pchickey submitted PR Review.
peterhuene updated PR #2620 from fix-fd-readdir to main:
Previously,
fd_readdirwas truncating directory entry names based on the
calculation ofmin(name_len, buf_len - bufused), butbufusedwas not being
updated after writing in thedirentstructure to the buffer.This allowed
bufusedto be incremented beyondbuf_lenand returned as the
number of bytes written to the buffer, which is invalid.This fix adjusts
bufusedwhen the buffer is written to for thedirentso
that name truncation happens as expected.Fixes #2618.
peterhuene merged PR #2620.
Last updated: Dec 13 2025 at 19:03 UTC