-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
Description
The id -p command can cause a segmentation fault when it is invoked without any users as arguments.
$ target/release/id -p
Segmentation fault (core dumped)
$ target/release/id -p root
uid root
groups rootThe segmentation fault happens when the getlogin function call returns a NULL pointer. The cstr2cow macro fails as it is invoked with a NULL pointer instead of a valid C string.
getlogin() returns a pointer to a string containing the name of the user logged in on the controlling terminal of the process, or a NULL pointer if this information cannot be determined.
Environment
cargo --version: cargo 1.88.0-nightly (d811228b1 2025-04-15)- OS: Ubuntu 22.04.5 LTS on Windows 10 x86_64
- Kernel: 5.15.167.4-microsoft-standard-WSL2
- Shell: bash 5.1.16
- Terminal: Windows Terminal