[Pkg-rust-maintainers] Bug#1107270: rust-coreutils: incorrect evaluation in expr command

Heinrich Schuchardt heinrich.schuchardt at canonical.com
Wed Jun 4 11:42:36 BST 2025


Package: rust-coreutils
Version: 0.0.30-2
Severity: Normal

The following problem was reported in
https://bugs.launchpad.net/ubuntu/+source/rust-coreutils/+bug/2112445
and in upstream
https://github.com/uutils/coreutils/issues/8063

/usr/lib/cargo/bin/coreutils/expr does not correctly evaluate
`expr substr` in the following script:

#!/bin/sh
list='alpha avr hppa m68k loongarch64 (loong64) microblaze microblazeel 
or1k rx sh4 sh4eb tricore xtensa xtensaeb'; \
echo $list; \
len2=$((${#list}/2)); echo len2 = $len2; \
len2=$((${#list}/2)); \
if [ $len2 -gt 36 ]; then \
   while expr substr "$list" $len2 1 != " " >/dev/null; do \
     len2=$(($len2+1)); \
     echo $len2; \
   done; \
   list="$(expr substr "$list" 1 $(($len2-1)))\${Newline} $(expr substr 
"$list" $(($len2+1)) $len2)"; \
fi;

Output in gnu-coreutils:

alpha avr hppa m68k loongarch64 (loong64) microblaze microblazeel or1k 
rx sh4 sh4eb tricore xtensa xtensaeb
len2 = 53

Output in rust-coreutils:

alpha avr hppa m68k loongarch64 (loong64) microblaze microblazeel or1k 
rx sh4 sh4eb tricore xtensa xtensaeb
len2 = 53
54
55
56
57
[...]

Best regards

Heinrich



More information about the Pkg-rust-maintainers mailing list