#38096 [Opn->Csd]: stream_socket_accept : big timeout values are not taken into account

From: Date: Mon, 11 Sep 2006 14:53:38 +0000
Subject: #38096 [Opn->Csd]: stream_socket_accept : big timeout values are not taken into account
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-101996@lists.php.net to get a copy of this message
ID: 38096 Updated by: iliaa@php.net Reported By: daniel dot menard at bdsp dot tm dot fr -Status: Open +Status: Closed Bug Type: Streams related Operating System: Win XP PHP Version: 5.1.4 New Comment: This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2006-07-13 14:50:37] daniel dot menard at bdsp dot tm dot fr Description: ------------ Time-out values passed to stream_socket_accept are not always taken into account has they should be. Values from 0 to 4294 seconds work fine, greater values do not (4295 is equivalent to 0 sec, 4296 to 1 sec and so on). From current cvs source, it appears that the timeout parameter is multiplied and then cast to an unsigned long which results in an overflow for values greater than 4294: http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/streamsfuncs.c?view=annotate line 247 : /* prepare the timeout value for use */ conv = (unsigned long) (timeout * 1000000.0); tv.tv_sec = conv / 1000000; tv.tv_usec = conv % 1000000; Note: similar code can be found for stream_socket_client. Perhaps there are good reasons to not accept such timeout values. In this case, raising a 'bad parameter' exception and a note in the documentation would be better options than silently accept the overflow. Otherwise, a solution would be to test for big values: if (timeout>4294){tv.tv_sec=timeout; tv.tv_usec=0;} else { /* actual code */ } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=38096&edit=1

« previous php.bugs (#101996) next »