Skip to content

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

Closed

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):

  • --version — print!("{}", app.render_version()) (mod.rs:599)
  • match output — println!("{}", …) / print!("{}\0", …) (mod.rs:649/651)
  • -c / count — println!("{count}") (mod.rs:671)
  • -S / --statistics — the whole Statistics::print / print_header
    block, ~10 println! calls (mod.rs:117–144)
$ 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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