[Bug 15051] New: [PATCH] Awk: fix bitwise functions result/arguments truncation on 32bit platforms
bugzilla at busybox.net
bugzilla at busybox.net
Sun Oct 9 11:54:05 UTC 2022
https://bugs.busybox.net/show_bug.cgi?id=15051
Bug ID: 15051
Summary: [PATCH] Awk: fix bitwise functions result/arguments
truncation on 32bit platforms
Product: Busybox
Version: unspecified
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P5
Component: Other
Assignee: unassigned at busybox.net
Reporter: caribpa at outlook.com
CC: busybox-cvs at busybox.net
Target Milestone: ---
Created attachment 9386
--> https://bugs.busybox.net/attachment.cgi?id=9386&action=edit
awk-bitwise-fix-arch32.patch
Hi!
On platforms that use 32bit longs data is lost when performing bitwise
operations if the result and/or arguments are equal-to/greater-than 2^32.
This behavior is unexpected as Busybox Awk numbers are doubles[1] (typically up
to 2^53) and this issue is not present on GNU Awk.
Example 1 - Result equal-to/greater-than 2^32:
awk 'BEGIN{print lshift(1, 32)}'
It returns 1, instead of the expected 4294967296.
Example 2 - Arguments equal-to/greater-than 2^32:
awk 'BEGIN{print and(2^32, 2^32)}'
It returns 0, instead of the expected 4294967296.
The patch attached simply changes the castings and type of the getvar_i_int
function from long to long long.
Note that the patch found in bug 15036[3] adds two functions that
operate/return long numbers that shall also be changed into long long when
accepted.
Cheers,
Carlos
[1] -
https://git.busybox.net/busybox/tree/editors/awk.c?id=c8c1fcdba163f264a503380bc63485aacd09214c#n123
[2] -
https://git.busybox.net/busybox/tree/editors/awk.c?id=c8c1fcdba163f264a503380bc63485aacd09214c#n1048
[3] - https://bugs.busybox.net/show_bug.cgi?id=15036
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the busybox-cvs
mailing list