Bug 13926 - test command does not range-check properly
Summary: test command does not range-check properly
Status: NEW
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: 2021-07-06 09:43 UTC by Vladimír Čunát
Modified: 2021-07-06 09:43 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments
patch fixing the range check (875 bytes, patch)
2021-07-06 09:43 UTC, Vladimír Čunát
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimír Čunát 2021-07-06 09:43:05 UTC
Created attachment 9046 [details]
patch fixing the range check

In "default settings" it just won't work:
$ sh -c 'test 2845170688 -lt 1; echo $?'
0

Using 32-bit arithmetic in test on 64-bit systems... is a bit weird default to me, but at least I propose to fix the range check.  For reference, we ran into this on https://github.com/NixOS/nixpkgs/issues/110149

Please apply the attached patch.  By the way, I originally wanted to just submit it to the mailing-list, but that would require me to subscribe to *all* of the list.

Of course, not everyone is affected.  Many will have CONFIG_FEATURE_TEST_64 so they don't have such low bound and perhaps `int64_t` will equal `long long`, and some platforms even have 64-bit `int`.