diff options
author | Rob Landley <rob@landley.net> | 2019-07-30 13:09:05 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2019-07-30 13:09:05 -0500 |
commit | 6b617d8073600c9f2518c87addc49a89a27d887e (patch) | |
tree | eac233534a76b224f41d1e468da3b4eb4f660733 /toys/posix | |
parent | e4dd5350882fde0cc82741e9b424037f35887f96 (diff) | |
download | toybox-6b617d8073600c9f2518c87addc49a89a27d887e.tar.gz |
Fix signed typecast bug.
We use (char *)1 and (char *)2 to indicate errors (they can never be valid
pointers because both malloc() and mmap() return aligned memory and those
align down to NULL, plus Linux maps 4k at the bottom to catch null
dereferences anyway), and then typecast it to long (trusting in LP64) to
do an integer <=2 comparison... except that needs to be UNSIGNED long or
else pointers in the top half of the virtual memory space become negative
and the <=2 false positives them as errors. (Oops.)
Diffstat (limited to 'toys/posix')
-rw-r--r-- | toys/posix/xargs.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/toys/posix/xargs.c b/toys/posix/xargs.c index 12af9125..39d78ef5 100644 --- a/toys/posix/xargs.c +++ b/toys/posix/xargs.c @@ -161,7 +161,7 @@ void xargs_main(void) data = handle_entries(data, NULL); if (!data) continue; if (data == (char *)2) done++; - if ((long)data <= 2) data = 0; + if ((unsigned long)data <= 2) data = 0; else data = xstrdup(data); break; |