[PHP-DEV] Bug #10686 Updated: Bug in mktime() on values out of bounds

2002-01-08 Thread derick

ID: 10686
Updated by: derick
Reported By: [EMAIL PROTECTED]
Old Status: Assigned
Status: Closed
Bug Type: Date/time related
Operating System: MacOS X 10.0.2 (Darwin)
PHP Version: 4.0.5
Old Assigned To: kalowsky
Assigned To: 
New Comment:

This is reported fixed.

Previous Comments:


[2001-11-18 02:37:56] [EMAIL PROTECTED]

From: Abner Diaz [EMAIL PROTECTED]

I can verify the behavior of PHP Bug ID 10686 (http://
bugs.php.net/bug.php?id=10686), regarding mktime 
malfunctions in OS X 10.1/Darwin 1.4.   The fixes to 
datetime.c posted by [EMAIL PROTECTED] worked well.  
Thanks!
 
Sincerely,
Abner Diaz




[2001-10-23 09:03:49] [EMAIL PROTECTED]

Does it looks well? (Same in MacOS X 10.1 and Darwin 1.4.1)



[2001-08-18 21:30:34] [EMAIL PROTECTED]

i have a MacOSX box now so I'll test this out and submit it 
if it looks good...



[2001-06-11 14:28:32] [EMAIL PROTECTED]

 you can use Darwin/Intel (see: http://www.darwinfo.de), if  

Sorry. Informations about Darwin you can find on:
- http://www.darwinfo.org/
- http://www.apple.com/darwin/

Dieter




[2001-06-09 07:38:48] [EMAIL PROTECTED]

Von: Trevis Tagawa [EMAIL PROTECTED]
Datum: Sam, 09. Jun. 2001  01:12:46 Europe/Berlin
An: [EMAIL PROTECTED]
Betreff: Thanks!

just wanted to extend a thanks to you for posting the fix.  searched the
net
high and low but found your fix on the php site.  aloha!  trevis.

-

Trevis Tagawa
Instructional Systems Analyst
Kamehameha Schools
1887 Makuakane Street
Honolulu, HI  96817




The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/?id=10686


Edit this bug report at http://bugs.php.net/?id=10686edit=1


-- 
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]




[PHP-DEV] Bug #10686 Updated: Bug in mktime() on values out of bounds

2001-11-17 Thread dieter

ID: 10686
User updated by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
Status: Assigned
Bug Type: Date/time related
Operating System: MacOS X 10.0.2 (Darwin)
PHP Version: 4.0.5
Old Assigned To: kalowsky
Assigned To: 
New Comment:

From: Abner Diaz [EMAIL PROTECTED]

I can verify the behavior of PHP Bug ID 10686 (http://
bugs.php.net/bug.php?id=10686), regarding mktime 
malfunctions in OS X 10.1/Darwin 1.4.   The fixes to 
datetime.c posted by [EMAIL PROTECTED] worked well.  
Thanks!
 
Sincerely,
Abner Diaz


Previous Comments:


[2001-10-23 09:03:49] [EMAIL PROTECTED]

Does it looks well? (Same in MacOS X 10.1 and Darwin 1.4.1)



[2001-08-18 21:30:34] [EMAIL PROTECTED]

i have a MacOSX box now so I'll test this out and submit it 
if it looks good...



[2001-06-11 14:28:32] [EMAIL PROTECTED]

 you can use Darwin/Intel (see: http://www.darwinfo.de), if  

Sorry. Informations about Darwin you can find on:
- http://www.darwinfo.org/
- http://www.apple.com/darwin/

Dieter




[2001-06-09 07:38:48] [EMAIL PROTECTED]

Von: Trevis Tagawa [EMAIL PROTECTED]
Datum: Sam, 09. Jun. 2001  01:12:46 Europe/Berlin
An: [EMAIL PROTECTED]
Betreff: Thanks!

just wanted to extend a thanks to you for posting the fix.  searched the net
high and low but found your fix on the php site.  aloha!  trevis.

-

Trevis Tagawa
Instructional Systems Analyst
Kamehameha Schools
1887 Makuakane Street
Honolulu, HI  96817




[2001-05-14 14:59:14] [EMAIL PROTECTED]

Ill look into getting darwin x86 tomorrow.

- James



The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/?id=10686


Edit this bug report at http://bugs.php.net/?id=10686edit=1


-- 
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]




[PHP-DEV] Bug #10686 Updated: Bug in mktime() on values out of bounds

2001-10-23 Thread dieter

ID: 10686
User updated by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
Status: Assigned
Bug Type: Date/time related
Operating System: MacOS X 10.0.2 (Darwin)
PHP Version: 4.0.5
Old Assigned To: kalowsky
Assigned To: 
New Comment:

Does it looks well? (Same in MacOS X 10.1 and Darwin 1.4.1)

Previous Comments:


[2001-08-18 21:30:34] [EMAIL PROTECTED]

i have a MacOSX box now so I'll test this out and submit it 
if it looks good...



[2001-06-11 14:28:32] [EMAIL PROTECTED]

 you can use Darwin/Intel (see: http://www.darwinfo.de), if  

Sorry. Informations about Darwin you can find on:
- http://www.darwinfo.org/
- http://www.apple.com/darwin/

Dieter




[2001-06-09 07:38:48] [EMAIL PROTECTED]

Von: Trevis Tagawa [EMAIL PROTECTED]
Datum: Sam, 09. Jun. 2001  01:12:46 Europe/Berlin
An: [EMAIL PROTECTED]
Betreff: Thanks!

just wanted to extend a thanks to you for posting the fix.  searched the net
high and low but found your fix on the php site.  aloha!  trevis.

-

Trevis Tagawa
Instructional Systems Analyst
Kamehameha Schools
1887 Makuakane Street
Honolulu, HI  96817




[2001-05-14 14:59:14] [EMAIL PROTECTED]

Ill look into getting darwin x86 tomorrow.

- James



[2001-05-14 14:53:55] [EMAIL PROTECTED]

Yes, it is Darwin specific.
It is enough to use MacOS X 10.0.0 to 10.0.3 (MacOS X 
Server is not need!)
OR
you can use Darwin/Intel (see: http://www.darwinfo.de), if 
you don't have a Apple Macintosh.

I used this patch for some weeks and an more primitiv patch 
some month. It works well and it can test on all other 
platforms you have. I will made some more test with some 
bigger values for each field...


Whats the problem? You are using an undocumented feature 
and all other UNIX work in the same way. But it is not 
safe!

Dieter




The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/?id=10686


Edit this bug report at http://bugs.php.net/?id=10686edit=1


-- 
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]




[PHP-DEV] Bug #10686 Updated: Bug in mktime() on values out of bounds

2001-08-18 Thread kalowsky

ID: 10686
Updated by: kalowsky
Reported By: [EMAIL PROTECTED]
Old Status: Open
Status: Assigned
Bug Type: Date/time related
Operating System: MacOS X 10.0.2 (Darwin)
PHP Version: 4.0.5
Old Assigned To: 
Assigned To: kalowsky
New Comment:

i have a MacOSX box now so I'll test this out and submit it 
if it looks good...

Previous Comments:


[2001-06-11 14:28:32] [EMAIL PROTECTED]

 you can use Darwin/Intel (see: http://www.darwinfo.de), if  

Sorry. Informations about Darwin you can find on:
- http://www.darwinfo.org/
- http://www.apple.com/darwin/

Dieter




[2001-06-09 07:38:48] [EMAIL PROTECTED]

Von: Trevis Tagawa [EMAIL PROTECTED]
Datum: Sam, 09. Jun. 2001  01:12:46 Europe/Berlin
An: [EMAIL PROTECTED]
Betreff: Thanks!

just wanted to extend a thanks to you for posting the fix.  searched the net
high and low but found your fix on the php site.  aloha!  trevis.

-

Trevis Tagawa
Instructional Systems Analyst
Kamehameha Schools
1887 Makuakane Street
Honolulu, HI  96817




[2001-05-14 14:59:14] [EMAIL PROTECTED]

Ill look into getting darwin x86 tomorrow.

- James



[2001-05-14 14:53:55] [EMAIL PROTECTED]

Yes, it is Darwin specific.
It is enough to use MacOS X 10.0.0 to 10.0.3 (MacOS X 
Server is not need!)
OR
you can use Darwin/Intel (see: http://www.darwinfo.de), if 
you don't have a Apple Macintosh.

I used this patch for some weeks and an more primitiv patch 
some month. It works well and it can test on all other 
platforms you have. I will made some more test with some 
bigger values for each field...


Whats the problem? You are using an undocumented feature 
and all other UNIX work in the same way. But it is not 
safe!

Dieter




[2001-05-14 14:27:59] [EMAIL PROTECTED]

MacOS specific. Not critical untill we can find some MacOS X servers for developers/QA 
Team to test on.

- James



The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/?id=10686


Edit this bug report at http://bugs.php.net/?id=10686edit=1


-- 
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]




[PHP-DEV] Bug #10686 Updated: Bug in mktime() on values out of bounds

2001-05-14 Thread jmoore

ID: 10686
Updated by: jmoore
Reported By: [EMAIL PROTECTED]
Old-Status: Critical
Status: Open
Bug Type: Date/time related
Operating system: 
PHP Version: 4.0.5
Assigned To: 
Comments:

MacOS specific. Not critical untill we can find some MacOS X servers for developers/QA 
Team to test on.

- James

Previous Comments:
---

[2001-05-07 12:53:07] [EMAIL PROTECTED]
Marking as fix before 4.0.6

---

[2001-05-05 17:19:37] [EMAIL PROTECTED]
see Bug id #8828, too!

On PHP documantation: 
mktime(hour,min,sec, year,0,mon) refers the last day of month 'mon-1'. On MacOS X this 
failed, there it refers the first day of month 'mon' and mktime(hour,min,sec,  
year,-1,mon) refers the last day of month 'mon-1'. 

On MacOS X 10.0.2 (Darwin 1.3): 
02.03  -- 983487600 -- 02.03 
01.03  -- 983401200 -- 01.03 
00.03  -- 983401200 -- 01.03 
-1.03  -- 983314800 -- 28.02 
-2.03  -- 983228400 -- 27.02 

i have check some UNIX-systems and i haven't found any man-page, where is describe 
what should be happend on tm_mday = 0.  The problem is happend on all values out of 
bounds, when using mktime()!

IMHO this is a undocumented feature, which is used by PHP. 
 
man mktime (Linux 2.2.13) 
   tm_mday   The day of the month, in the range 1 to 31. 
Sun Release 4.1 
   int tm_mday; /* day of month (1 - 31) */ 
SunOS 5.5 
   int  tm_mday;   /* day of the month - [1, 31] */ 
HP-UX Release 10.20 
   int tm_mday; /* day of month - [1,31] */ 
HP-UX Release 11.00 
   int tm_mday; /* day of month - [1,31] */ 
AIX 4.3.2 
   int tm_mday;/* Day of month (1 - 31) */ 
Darwin 1.0.2 
   int tm_mday; /* day of month (1 - 31) */ 
 
I think i should by much better to check mktime() on configure and set a #define for 
compilation. Only on datetime.c must be made a patch to support MacOS X's / Darwin's 
mktime()-systemcall, i think! 


Patch to make php_mktime() more compatible [i think it is not complete for the whole 
PHP4-project]. It includes a time correction for values less then 1 on mday,
hour, min, sec, mon!! 
 
 
*** ext/standard/datetime.c.origFri Dec  8 12:38:02 2000 
--- ext/standard/datetime.c Sun Apr 15 17:28:46 2001 
*** 
*** 81,87  
struct tm *ta, tmbuf; 
time_t t; 
int i, gmadjust, seconds, arg_count = ZEND_NUM_ARGS(); 
!   int is_dst = -1; 
   
if (arg_count  7 ||  
zend_get_parameters_array_ex(arg_count,arguments) ==  
FAILURE) { 
WRONG_PARAM_COUNT; 
--- 81,87  
struct tm *ta, tmbuf; 
time_t t; 
int i, gmadjust, seconds, arg_count = ZEND_NUM_ARGS(); 
!   int is_dst = -1, val, chgsecs = 0; 
   
if (arg_count  7 ||  
zend_get_parameters_array_ex(arg_count,arguments) ==  
FAILURE) { 
WRONG_PARAM_COUNT; 
*** 
*** 148,172  
  - (((*arguments[5])-value.lval  1000) ? 1900 : 0); 
/* fall-through */ 
case 5: 
!   ta-tm_mday = (*arguments[4])-value.lval; 
/* fall-through */ 
case 4: 
!   ta-tm_mon = (*arguments[3])-value.lval - 1; 
/* fall-through */ 
case 3: 
!   ta-tm_sec = (*arguments[2])-value.lval; 
/* fall-through */ 
case 2: 
!   ta-tm_min = (*arguments[1])-value.lval; 
/* fall-through */ 
case 1: 
!   ta-tm_hour = (*arguments[0])-value.lval; 
/* fall-through */ 
case 0: 
break; 
} 
   
!   seconds = mktime(ta); 
if (is_dst == -1) 
is_dst = ta-tm_isdst; 
   
--- 148,182  
  - (((*arguments[5])-value.lval  1000) ? 1900 : 0); 
/* fall-through */ 
case 5: 
!   val = (*arguments[4])-value.lval; 
!   if (val  1) { chgsecs += (1-val) * 60*60*24; val = 1;  
} 
!   ta-tm_mday = val; 
/* fall-through */ 
case 4: 
!   val = (*arguments[3])-value.lval - 1; 
!   while (val  0) { val += 12; ta-tm_year--; } 
!   ta-tm_mon = val; 
/* fall-through */ 
case 3: 
!   val = (*arguments[2])-value.lval; 
!   if (val  1) { chgsecs += (1-val); val = 1; } 
!   ta-tm_sec = val; 
/* fall-through */ 
case 2: 
!   val = (*arguments[1])-value.lval; 
!   if (val  1) { chgsecs += (1-val) * 60; val = 1; } 
!   ta-tm_min = val; 
/* fall-through */ 
case 1: 
!   val = (*arguments[0])-value.lval; 
!   if (val  1) { chgsecs 

[PHP-DEV] Bug #10686 Updated: Bug in mktime() on values out of bounds

2001-05-14 Thread dieter

ID: 10686
User Update by: [EMAIL PROTECTED]
Status: Open
Bug Type: Date/time related
Operating system: MacOS X 10.0.2 (Darwin)
PHP Version: 4.0.5
Description: Bug in mktime() on values out of bounds

Yes, it is Darwin specific.
It is enough to use MacOS X 10.0.0 to 10.0.3 (MacOS X 
Server is not need!)
OR
you can use Darwin/Intel (see: http://www.darwinfo.de), if 
you don't have a Apple Macintosh.

I used this patch for some weeks and an more primitiv patch 
some month. It works well and it can test on all other 
platforms you have. I will made some more test with some 
bigger values for each field...


Whats the problem? You are using an undocumented feature 
and all other UNIX work in the same way. But it is not 
safe!

Dieter


Previous Comments:
---

[2001-05-14 14:27:59] [EMAIL PROTECTED]
MacOS specific. Not critical untill we can find some MacOS X servers for developers/QA 
Team to test on.

- James

---

[2001-05-07 12:53:07] [EMAIL PROTECTED]
Marking as fix before 4.0.6

---

[2001-05-05 17:19:37] [EMAIL PROTECTED]
see Bug id #8828, too!

On PHP documantation: 
mktime(hour,min,sec, year,0,mon) refers the last day of month 'mon-1'. On MacOS X this 
failed, there it refers the first day of month 'mon' and mktime(hour,min,sec,  
year,-1,mon) refers the last day of month 'mon-1'. 

On MacOS X 10.0.2 (Darwin 1.3): 
02.03  -- 983487600 -- 02.03 
01.03  -- 983401200 -- 01.03 
00.03  -- 983401200 -- 01.03 
-1.03  -- 983314800 -- 28.02 
-2.03  -- 983228400 -- 27.02 

i have check some UNIX-systems and i haven't found any man-page, where is describe 
what should be happend on tm_mday = 0.  The problem is happend on all values out of 
bounds, when using mktime()!

IMHO this is a undocumented feature, which is used by PHP. 
 
man mktime (Linux 2.2.13) 
   tm_mday   The day of the month, in the range 1 to 31. 
Sun Release 4.1 
   int tm_mday; /* day of month (1 - 31) */ 
SunOS 5.5 
   int  tm_mday;   /* day of the month - [1, 31] */ 
HP-UX Release 10.20 
   int tm_mday; /* day of month - [1,31] */ 
HP-UX Release 11.00 
   int tm_mday; /* day of month - [1,31] */ 
AIX 4.3.2 
   int tm_mday;/* Day of month (1 - 31) */ 
Darwin 1.0.2 
   int tm_mday; /* day of month (1 - 31) */ 
 
I think i should by much better to check mktime() on configure and set a #define for 
compilation. Only on datetime.c must be made a patch to support MacOS X's / Darwin's 
mktime()-systemcall, i think! 


Patch to make php_mktime() more compatible [i think it is not complete for the whole 
PHP4-project]. It includes a time correction for values less then 1 on mday,
hour, min, sec, mon!! 
 
 
*** ext/standard/datetime.c.origFri Dec  8 12:38:02 2000 
--- ext/standard/datetime.c Sun Apr 15 17:28:46 2001 
*** 
*** 81,87  
struct tm *ta, tmbuf; 
time_t t; 
int i, gmadjust, seconds, arg_count = ZEND_NUM_ARGS(); 
!   int is_dst = -1; 
   
if (arg_count  7 ||  
zend_get_parameters_array_ex(arg_count,arguments) ==  
FAILURE) { 
WRONG_PARAM_COUNT; 
--- 81,87  
struct tm *ta, tmbuf; 
time_t t; 
int i, gmadjust, seconds, arg_count = ZEND_NUM_ARGS(); 
!   int is_dst = -1, val, chgsecs = 0; 
   
if (arg_count  7 ||  
zend_get_parameters_array_ex(arg_count,arguments) ==  
FAILURE) { 
WRONG_PARAM_COUNT; 
*** 
*** 148,172  
  - (((*arguments[5])-value.lval  1000) ? 1900 : 0); 
/* fall-through */ 
case 5: 
!   ta-tm_mday = (*arguments[4])-value.lval; 
/* fall-through */ 
case 4: 
!   ta-tm_mon = (*arguments[3])-value.lval - 1; 
/* fall-through */ 
case 3: 
!   ta-tm_sec = (*arguments[2])-value.lval; 
/* fall-through */ 
case 2: 
!   ta-tm_min = (*arguments[1])-value.lval; 
/* fall-through */ 
case 1: 
!   ta-tm_hour = (*arguments[0])-value.lval; 
/* fall-through */ 
case 0: 
break; 
} 
   
!   seconds = mktime(ta); 
if (is_dst == -1) 
is_dst = ta-tm_isdst; 
   
--- 148,182  
  - (((*arguments[5])-value.lval  1000) ? 1900 : 0); 
/* fall-through */ 
case 5: 
!   val = (*arguments[4])-value.lval; 
!   if (val  1) { chgsecs += (1-val) * 60*60*24; val = 1;  
} 
!   ta-tm_mday = val; 
/* fall-through */ 
case 4: 
!   val = 

[PHP-DEV] Bug #10686 Updated: Bug in mktime() on values out of bounds

2001-05-14 Thread jmoore

ID: 10686
Updated by: jmoore
Reported By: [EMAIL PROTECTED]
Status: Open
Bug Type: Date/time related
Operating system: 
PHP Version: 4.0.5
Assigned To: 
Comments:

Ill look into getting darwin x86 tomorrow.

- James

Previous Comments:
---

[2001-05-14 14:53:55] [EMAIL PROTECTED]
Yes, it is Darwin specific.
It is enough to use MacOS X 10.0.0 to 10.0.3 (MacOS X 
Server is not need!)
OR
you can use Darwin/Intel (see: http://www.darwinfo.de), if 
you don't have a Apple Macintosh.

I used this patch for some weeks and an more primitiv patch 
some month. It works well and it can test on all other 
platforms you have. I will made some more test with some 
bigger values for each field...


Whats the problem? You are using an undocumented feature 
and all other UNIX work in the same way. But it is not 
safe!

Dieter


---

[2001-05-14 14:27:59] [EMAIL PROTECTED]
MacOS specific. Not critical untill we can find some MacOS X servers for developers/QA 
Team to test on.

- James

---

[2001-05-07 12:53:07] [EMAIL PROTECTED]
Marking as fix before 4.0.6

---

[2001-05-05 17:19:37] [EMAIL PROTECTED]
see Bug id #8828, too!

On PHP documantation: 
mktime(hour,min,sec, year,0,mon) refers the last day of month 'mon-1'. On MacOS X this 
failed, there it refers the first day of month 'mon' and mktime(hour,min,sec,  
year,-1,mon) refers the last day of month 'mon-1'. 

On MacOS X 10.0.2 (Darwin 1.3): 
02.03  -- 983487600 -- 02.03 
01.03  -- 983401200 -- 01.03 
00.03  -- 983401200 -- 01.03 
-1.03  -- 983314800 -- 28.02 
-2.03  -- 983228400 -- 27.02 

i have check some UNIX-systems and i haven't found any man-page, where is describe 
what should be happend on tm_mday = 0.  The problem is happend on all values out of 
bounds, when using mktime()!

IMHO this is a undocumented feature, which is used by PHP. 
 
man mktime (Linux 2.2.13) 
   tm_mday   The day of the month, in the range 1 to 31. 
Sun Release 4.1 
   int tm_mday; /* day of month (1 - 31) */ 
SunOS 5.5 
   int  tm_mday;   /* day of the month - [1, 31] */ 
HP-UX Release 10.20 
   int tm_mday; /* day of month - [1,31] */ 
HP-UX Release 11.00 
   int tm_mday; /* day of month - [1,31] */ 
AIX 4.3.2 
   int tm_mday;/* Day of month (1 - 31) */ 
Darwin 1.0.2 
   int tm_mday; /* day of month (1 - 31) */ 
 
I think i should by much better to check mktime() on configure and set a #define for 
compilation. Only on datetime.c must be made a patch to support MacOS X's / Darwin's 
mktime()-systemcall, i think! 


Patch to make php_mktime() more compatible [i think it is not complete for the whole 
PHP4-project]. It includes a time correction for values less then 1 on mday,
hour, min, sec, mon!! 
 
 
*** ext/standard/datetime.c.origFri Dec  8 12:38:02 2000 
--- ext/standard/datetime.c Sun Apr 15 17:28:46 2001 
*** 
*** 81,87  
struct tm *ta, tmbuf; 
time_t t; 
int i, gmadjust, seconds, arg_count = ZEND_NUM_ARGS(); 
!   int is_dst = -1; 
   
if (arg_count  7 ||  
zend_get_parameters_array_ex(arg_count,arguments) ==  
FAILURE) { 
WRONG_PARAM_COUNT; 
--- 81,87  
struct tm *ta, tmbuf; 
time_t t; 
int i, gmadjust, seconds, arg_count = ZEND_NUM_ARGS(); 
!   int is_dst = -1, val, chgsecs = 0; 
   
if (arg_count  7 ||  
zend_get_parameters_array_ex(arg_count,arguments) ==  
FAILURE) { 
WRONG_PARAM_COUNT; 
*** 
*** 148,172  
  - (((*arguments[5])-value.lval  1000) ? 1900 : 0); 
/* fall-through */ 
case 5: 
!   ta-tm_mday = (*arguments[4])-value.lval; 
/* fall-through */ 
case 4: 
!   ta-tm_mon = (*arguments[3])-value.lval - 1; 
/* fall-through */ 
case 3: 
!   ta-tm_sec = (*arguments[2])-value.lval; 
/* fall-through */ 
case 2: 
!   ta-tm_min = (*arguments[1])-value.lval; 
/* fall-through */ 
case 1: 
!   ta-tm_hour = (*arguments[0])-value.lval; 
/* fall-through */ 
case 0: 
break; 
} 
   
!   seconds = mktime(ta); 
if (is_dst == -1) 
is_dst = ta-tm_isdst; 
   
--- 148,182  
  - (((*arguments[5])-value.lval  1000) ? 1900 : 0); 
/* fall-through */ 
case 5: 
!   val = (*arguments[4])-value.lval; 
!   if (val  1) { chgsecs += (1-val) * 

[PHP-DEV] Bug #10686 Updated: Bug in mktime() on values out of bounds

2001-05-07 Thread derick

ID: 10686
Updated by: derick
Reported By: [EMAIL PROTECTED]
Old-Status: Open
Status: Critical
Bug Type: Date/time related
Operating system: 
PHP Version: 4.0.5
Assigned To: 
Comments:

Marking as fix before 4.0.6

Previous Comments:
---

[2001-05-05 17:19:37] [EMAIL PROTECTED]
see Bug id #8828, too!

On PHP documantation: 
mktime(hour,min,sec, year,0,mon) refers the last day of month 'mon-1'. On MacOS X this 
failed, there it refers the first day of month 'mon' and mktime(hour,min,sec,  
year,-1,mon) refers the last day of month 'mon-1'. 

On MacOS X 10.0.2 (Darwin 1.3): 
02.03  -- 983487600 -- 02.03 
01.03  -- 983401200 -- 01.03 
00.03  -- 983401200 -- 01.03 
-1.03  -- 983314800 -- 28.02 
-2.03  -- 983228400 -- 27.02 

i have check some UNIX-systems and i haven't found any man-page, where is describe 
what should be happend on tm_mday = 0.  The problem is happend on all values out of 
bounds, when using mktime()!

IMHO this is a undocumented feature, which is used by PHP. 
 
man mktime (Linux 2.2.13) 
   tm_mday   The day of the month, in the range 1 to 31. 
Sun Release 4.1 
   int tm_mday; /* day of month (1 - 31) */ 
SunOS 5.5 
   int  tm_mday;   /* day of the month - [1, 31] */ 
HP-UX Release 10.20 
   int tm_mday; /* day of month - [1,31] */ 
HP-UX Release 11.00 
   int tm_mday; /* day of month - [1,31] */ 
AIX 4.3.2 
   int tm_mday;/* Day of month (1 - 31) */ 
Darwin 1.0.2 
   int tm_mday; /* day of month (1 - 31) */ 
 
I think i should by much better to check mktime() on configure and set a #define for 
compilation. Only on datetime.c must be made a patch to support MacOS X's / Darwin's 
mktime()-systemcall, i think! 


Patch to make php_mktime() more compatible [i think it is not complete for the whole 
PHP4-project]. It includes a time correction for values less then 1 on mday,
hour, min, sec, mon!! 
 
 
*** ext/standard/datetime.c.origFri Dec  8 12:38:02 2000 
--- ext/standard/datetime.c Sun Apr 15 17:28:46 2001 
*** 
*** 81,87  
struct tm *ta, tmbuf; 
time_t t; 
int i, gmadjust, seconds, arg_count = ZEND_NUM_ARGS(); 
!   int is_dst = -1; 
   
if (arg_count  7 ||  
zend_get_parameters_array_ex(arg_count,arguments) ==  
FAILURE) { 
WRONG_PARAM_COUNT; 
--- 81,87  
struct tm *ta, tmbuf; 
time_t t; 
int i, gmadjust, seconds, arg_count = ZEND_NUM_ARGS(); 
!   int is_dst = -1, val, chgsecs = 0; 
   
if (arg_count  7 ||  
zend_get_parameters_array_ex(arg_count,arguments) ==  
FAILURE) { 
WRONG_PARAM_COUNT; 
*** 
*** 148,172  
  - (((*arguments[5])-value.lval  1000) ? 1900 : 0); 
/* fall-through */ 
case 5: 
!   ta-tm_mday = (*arguments[4])-value.lval; 
/* fall-through */ 
case 4: 
!   ta-tm_mon = (*arguments[3])-value.lval - 1; 
/* fall-through */ 
case 3: 
!   ta-tm_sec = (*arguments[2])-value.lval; 
/* fall-through */ 
case 2: 
!   ta-tm_min = (*arguments[1])-value.lval; 
/* fall-through */ 
case 1: 
!   ta-tm_hour = (*arguments[0])-value.lval; 
/* fall-through */ 
case 0: 
break; 
} 
   
!   seconds = mktime(ta); 
if (is_dst == -1) 
is_dst = ta-tm_isdst; 
   
--- 148,182  
  - (((*arguments[5])-value.lval  1000) ? 1900 : 0); 
/* fall-through */ 
case 5: 
!   val = (*arguments[4])-value.lval; 
!   if (val  1) { chgsecs += (1-val) * 60*60*24; val = 1;  
} 
!   ta-tm_mday = val; 
/* fall-through */ 
case 4: 
!   val = (*arguments[3])-value.lval - 1; 
!   while (val  0) { val += 12; ta-tm_year--; } 
!   ta-tm_mon = val; 
/* fall-through */ 
case 3: 
!   val = (*arguments[2])-value.lval; 
!   if (val  1) { chgsecs += (1-val); val = 1; } 
!   ta-tm_sec = val; 
/* fall-through */ 
case 2: 
!   val = (*arguments[1])-value.lval; 
!   if (val  1) { chgsecs += (1-val) * 60; val = 1; } 
!   ta-tm_min = val; 
/* fall-through */ 
case 1: 
!   val = (*arguments[0])-value.lval; 
!   if (val  1) { chgsecs += (1-val) * 60*60; val = 1; } 
!   ta-tm_hour = val; 
/* fall-through */ 
case 0: 
break; 
} 
   
!   seconds = mktime(ta) - chgsecs; 
if (is_dst == -1)