Skip to content

Crash (abort) doing completion on filenames >= 256 bytes #11221

@g2p

Description

@g2p

This is possible on bcachefs (stat --file-system /mnt/bcachefs says 512 bytes in a dirent, koverstreet/bcachefs#733 has a test script; not sure if that limit includes a final NUL).

Create the file like this:

i=256; touch "$(printf "%05d" ${i})$(head -c $((${i}-5)) /dev/zero | tr '\0' 'a')"

The backtrace looks like (as of 49023ad):

   5: fish::common::cstr2wcstring
             at ./src/common.rs:1185:18
   6: fish::wutil::dir_iter::DirIter::next
             at ./src/wutil/dir_iter.rs:282:27
   7: fish::wildcard::expander::WildCardExpander::expand_trailing_slash
             at ./src/wildcard.rs:667:41
   8: fish::wildcard::expander::WildCardExpander::expand
             at ./src/wildcard.rs:528:21

Apparently there are 256 byte slices in dirent structs returned from the libc crate: https://docs.rs/libc/latest/libc/struct.dirent.html
gdb can printf the rest of the string so the slice length is incorrect.
std's own read_dir will probably work better.

Metadata

Metadata

Assignees

No one assigned

    Labels

    regressionSomething that used to work, but was broken, especially between releases

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions