On Thu, 02 Aug 2001 19:16:26 +0200, "Stanislav Malyshev" <[EMAIL PROTECTED]>
wrote:

> TA>> By the way:
> TA>> I think that the decbin() function should bail out if you pass it
> a TA>> value which contains more bits than PHP is able to handle. -
> Perhaps TA>> with a hint about using GMP for large numbers.
> 
> I'd say "give a warning" istead of "bail out", but that's a good idea,
> generally.

OK. Here is a suggestion for an adjustment in math.c. The patch could
probably be improved: The check for strings with more than 31 chars
should probably be less hard-coded, but I'm not sure which contant to
use for determining maximum size of a LONG.

/Troels

--- php4-orig/ext/standard/math.c       Sun Aug  5 12:51:38 2001
+++ php4/ext/standard/math.c    Sun Aug  5 12:52:35 2001
@@ -813,6 +813,11 @@
        }
 
        convert_to_string_ex(arg);
+
+       if ((*arg)->value.str.len > 31) {
+               php_error(E_WARNING, "bindec: input string too long (max is a 31-bit 
+value)");
+       }
+
        ret = _php_math_basetolong(*arg, 2);
 
        RETVAL_LONG(ret);

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to