Bug 10526 - env: invalid number 'VAR' error when using `env -u VAR`
Summary: env: invalid number 'VAR' error when using `env -u VAR`
Status: RESOLVED FIXED
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: unspecified
Hardware: All All
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-28 00:22 UTC by Chris Renshaw
Modified: 2018-01-10 10:13 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Renshaw 2017-11-28 00:22:22 UTC
This occurs with `env -u VAR` and `env -u VAR=val`, but interestingly `env VAR=val`, `env -`, `env -i` and `env` all seem to work fine.

I have tested this going back several busybox versions (1.20.2 - 1.27.2), on my own and other public arm+arm64 Android builds as well as the official arm and i686 builds (https://busybox.net/downloads/binaries/1.26.2-defconfig-multiarch/) using my phone and my Ubuntu VM, respectively.

My attempts to debug it have only led to dead ends so far, including trying swapping out the putenv for the commented unsetenv with no luck, but I do know that toybox env -u does work on Android and uses putenv and unsetenv, so it should be possible on that platform and this just seems to be a larger busybox issue overall, independent of platform/architecture.

Let me know if there's anything else I can provide to help debug or fix it.
Comment 1 Jean-Louis Fuchs 2017-12-24 22:04:09 UTC
Here my tests:

$> sudo docker run -ti --rm busybox
/ # busybox
BusyBox v1.27.2 (2017-11-01 22:58:00 UTC) multi-call binary.
...
/ # env -u HOME env
env: invalid number 'HOME'
/ # env -u 1 env
Segmentation fault

Since it said invalid number I tried a number and got a segfault.
Comment 2 Denys Vlasenko 2018-01-10 10:13:40 UTC
Fixed in git:

commit 8d8ee910f0a624fefd2a4aaefeb406003dea7807
Author: Ron Yorston <rmy@pobox.com>
Date:   Mon Dec 25 21:36:05 2017 +0100

    env: -u option fails due to typo