Date: 12/28/99
- Next message: rasmus <email protected>: "RE: [PHP-DEV] 3.0.13 Release Candidate 1"
- Previous message: Bug Database: "[PHP-DEV] Bug #2954 Updated: feof doesn't always evaluate correctly"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
From: anderson <email protected>
Operating system: FreeBSD
PHP version: 3.0.12
PHP Bug Type: Misbehaving function
Bug description: dechex doesn't handle negative numbers
The function dechex() can be passed a negative number, which will
create a negative index into a static array. This was discoverd when trying to manipulate IP addresses represented by integers. Any IP that has a first octet >127 will cause this to happen. Since integers are signed, I wonder what other areas might have a similar problem when trying to manipulate IP addresses in this way.
Simple Example:
print(dechex(-333333));
This fix seems to correct this instance of the problem, but I fear that there could possibly be undesirable side effect of doing this.
*** php-3.0.12/functions/math.c Thu Apr 22 09:19:50 1999
--- php/functions/math.c Tue Dec 28 21:16:08 1999
***************
*** 424,430 ****
static char digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
char *result, *ptr, *ret;
int len, digit;
! long value;
if (arg->type != IS_LONG || base < 2 || base > 36) {
return empty_string;
--- 424,430 ----
static char digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
char *result, *ptr, *ret;
int len, digit;
! unsigned long value;
if (arg->type != IS_LONG || base < 2 || base > 36) {
return empty_string;
-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: rasmus <email protected>: "RE: [PHP-DEV] 3.0.13 Release Candidate 1"
- Previous message: Bug Database: "[PHP-DEV] Bug #2954 Updated: feof doesn't always evaluate correctly"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

