|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-11-05 18:35 UTC] php_bug at cklowe dot com
Description: ------------ Large integers are being saturated to the maximum signed value (0x7fffffff) as opposed to being treated as the unsigned values. Panic! I had code that set the high bit in a Permissions variable when some condition was met. After changing PHP versions because of bug 25570, I found user reports of "Why have I got all these additional permissions?" and "I've now got Admin rights, OOoooh. What happens if I run this SQL query in the page I now have access to?". Reproduce code: --------------- define ("BIG_NUM", 0x80000000); $big_var = 0x80000000; echo sprintf("%08x, %08x", BIG_NUM, $big_var); Expected result: ---------------- 80000000,80000000 Actual result: -------------- 7fffffff, 7fffffff PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 16:00:01 2025 UTC |
>This is *not* a signed/unsigned integer problem No, why? It is. And it can be clearly seen in this example: <? define ("BIG_NUM", 0x80000000); $big_var = 0x80000000; printf("%u, %u\n", BIG_NUM, $big_var); printf("%f, %f\n", BIG_NUM, $big_var); ?> Overflown integers are treated as floats and you cannot use bitwise operators on floats (as I understand you use them to check access privileges).Brilliant stuff. I'm really glad this is fixed. It would appear that this bug also affects version 5.0.2. $big_var = 0x40000000; echo sprintf("%08x, %08x", $big_var * 2, $big_var << 1); ----- gives ---- 7fffffff, 80000000 which is OK if not entirely consistent with most other languages. But there is still no way to represent bit patterns with the high bit set, which is a pity. I believe your fix or an equivalent should go onto the 5 branch, too. What do you think?