Bug 13926

Summary: test command does not range-check properly
Product: Busybox Reporter: Vladimír Čunát <vcunat>
Component: OtherAssignee: unassigned
Status: NEW ---    
Severity: normal CC: busybox-cvs
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Host: Target:
Build:
Attachments: patch fixing the range check

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`.