Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Program panic on non-UTF-8 env vars

Open Beginner friendly
#346 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
backend

Research direction

Read the four std::env::vars() call sites listed in src/shadow-core/src/hardening.rs, src/uu/login/src/login.rs, and src/uu/newgrp/src/newgrp.rs, then check Rust’s environment iterator behavior for non-UTF-8 values. Determine how each call can avoid panicking when unrelated environment variables are invalid UTF-8. Done means all four paths handle such variables without a panic; the issue does not name tests to run.

Written by the indexing model from the issue text.

Description

I have not tested this, but from inspecting the source code, I think that some user-facing code in this repo will panic when faced with an environment variable that isn't valid UTF-8, regardless of whether the program actually needs those environment variables or not.

There are four places in the codebase that call std::env::vars():

https://github.com/uutils/shadow/blob/2e1032a2eef886308ae6c75133ec358637d415c3/src/shadow-core/src/hardening.rs#L102

https://github.com/uutils/shadow/blob/2e1032a2eef886308ae6c75133ec358637d415c3/src/shadow-core/src/hardening.rs#L176

https://github.com/uutils/shadow/blob/2e1032a2eef886308ae6c75133ec358637d415c3/src/uu/login/src/login.rs#L393

https://github.com/uutils/shadow/blob/2e1032a2eef886308ae6c75133ec358637d415c3/src/uu/newgrp/src/newgrp.rs#L186

As per the documentation, the iterator returned by vars() will panic when it encounters an environment variable that isn't valid UTF-8. This seems undesirable, since it's common for there to be irrelevant env vars hanging around when executing any program.

Dominant language
Rust
Stars
17
Forks
10
Avg merge
11h 22m
Merged PRs (30d)
13

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from uutils/shadow

All issues in uutils/shadow

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.