Skip to content

locate: panics when its output is redirected to /dev/full #769

Description

@leeewee

Every one of locate's stdout output paths uses print!/println!, which panic on a failed write.

The affected output paths (src/locate/mod.rs):

  • --versionprint!("{}", app.render_version()) (mod.rs:599)
  • match outputprintln!("{}", …) / print!("{}\0", …) (mod.rs:649/651)
  • -c / countprintln!("{count}") (mod.rs:671)
  • -S / --statistics — the whole Statistics::print / print_header
    block, ~10 println! calls (mod.rs:117144)
$ locate --version > /dev/full
thread 'main' panicked at library/std/src/io/stdio.rs:1165:9:
failed printing to stdout: No space left on device (os error 28)
$ echo $?
101

$ printf '\0LOCATE02\0\0/foo\0' > /tmp/db.bin
$ locate --statistics -d /tmp/db.bin foo > /dev/full
thread 'main' panicked at library/std/src/io/stdio.rs:1165:9: ...
$ locate -d /tmp/db.bin foo > /dev/full          # match output
thread 'main' panicked at library/std/src/io/stdio.rs:1165:9: ...
$ locate -c -d /tmp/db.bin foo > /dev/full        # count output
thread 'main' panicked at library/std/src/io/stdio.rs:1165:9: ...
$ echo $?
101

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions