Public bug reported:
In Ubuntu 25.10, if an environment variable or its value contains a UTF-8
character, coreutils will unwrap in Rust's library/std/src/env.rs.
Expected behavior is either to handle the UTF-8 character like any other
character or to print an error message.
Simple reproducer (tested with Bash):
STR=$(echo -e "foo\xA0")
# Generate environment variable 'foo' with UTF-8 value
foo=$STR env | grep foo
# Generate environment variable with UTF-8 name
declare "$STR=bar" ; env | grep $STR
The second command triggers this unwrap message in Ubuntu 25.10, but works fine
on Fedora 43:
thread 'main' panicked at library/std/src/env.rs:163:83:
called `Result::unwrap()` on an `Err` value: "foo\xA0"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
The third command fails with "declare: `foo�=bar': not a valid identifier"
(same on Ubuntu 25.10 and Fedora 43).
Using `printf -v` shows the same error message.
This behavior might be fine, but it can be bypassed by e.g. Perl:
#!/usr/bin/perl
$str = "foo\x{A0}";
$ENV{$str} = 'bar';
use open IN => ":raw";
my @env = `env`;
chomp (my @env = grep { s/^$str=// } @env);
die("@env not equal to 'bar'") if "@env" ne "bar"
This Perl script executes fine on Fedora 43, but triggers the following error
in Ubuntu 25.10:
thread 'main' panicked at library/std/src/env.rs:163:57:
called `Result::unwrap()` on an `Err` value: "foo\xA0"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
** Affects: coreutils (Ubuntu)
Importance: Undecided
Status: New
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2132941
Title:
Rust unwrap with UTF-8 symbols in environment variables
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/coreutils/+bug/2132941/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs