Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

env: a NUL byte in a `--file` entry reaches `std::env::set_var` unvalidated and aborts the process (exit 134)

未关闭 适合新手
#14,490 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
82/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
rust
领域
cli

调研方向

从 src/uu/env/src/env.rs 第 331-338 行附近开始,跟踪 --file 路径从已解析条目到 std::env::set_var 的过程;将其与会保护 argv 路径的 apply_specified_env_vars 进行比较。复现 issue 中 key 和 value 的 NUL 情况,然后验证两者都会产生诊断并以不触发 panic 的方式失败,而不是以 exit 134 退出。

由索引模型根据 Issue 内容生成。

描述

U - env

env --file FILE parses an .env/INI file and passes each key and value straight to std::env::set_var, which panics when either contains a NUL byte. A single NUL anywhere in the file therefore aborts env with a Rust panic instead of a diagnostic.

The argv path (env NAME=VALUE ...) is guarded — apply_specified_env_vars checks for an empty name before calling set_var, but the --file path has no guard at all.

Steps to reproduce

A NUL in the value:

$ printf 'KEY=a\x00b\n' > conf.env
$ env --file conf.env
thread 'main' panicked at library/std/src/env.rs:361:9:
failed to set environment variable `"KEY"` to `"a\0b"`: file name contained an unexpected NUL byte
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
$ echo $?
134

A NUL in the key does the same:

$ printf 'a\x00b=c\n' > k.env
$ env --file k.env       # exit 134, identical panic

Root cause

https://github.com/uutils/coreutils/blob/2c0e1b981fdce56bb8cc729dffed702ff0410e8e/src/uu/env/src/env.rs#L331-L338

std::env::set_var panics if either argument contains a NUL. Nothing between the parser and this call validates the bytes.

主要语言
Rust
星标
24.2k
派生
2.1k
平均合并
1 天 11 小时
30 天内合并 PR
333

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

uutils/coreutils 的其他 Issue

查看 uutils/coreutils 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。