Bug #17159 Updated: touch() is broken
| From: | derick@php.net | Date: | Sat, 11 May 2002 20:55:32 +0000 |
| Subject: | Bug #17159 Updated: touch() is broken | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-7457@lists.php.net to get a copy of this message | ||
ID: 17159
Updated by: derick@php.net
Reported By: sbriesen@gmx.de
-Status: Open
+Status: Closed
Bug Type: Reproducible crash
Operating System: linux, kernel 2.4.18
PHP Version: 4.2.0
New Comment:
This bug has been fixed in CVS. You can grab a snapshot of the
CVS version at http://snaps.php.net/. In case this was a
documentation
problem, the fix will show up soon at http://www.php.net/manual/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2002-05-11 16:54:28] sbriesen@gmx.de
In PHP 4.2.0 the touch() function seems to be broken!
When you use touch($filename) the mtime is a random value... if you use
touch($filename,time()), anything works fine.
I checked the source and I think, I found the BUG!
[php-4.2.0/ext/standard/filestat.c # PHP_FUNCTION(touch)]
[..]
struct utimbuf newtimebuf;
struct utimbuf *newtime = &newtimebuf;
int ac = ZEND_NUM_ARGS();
if (ac == 1 && zend_get_parameters_ex(1, &filename) != FAILURE)
{
#ifndef HAVE_UTIME_NULL
newtime->modtime = newtime->actime = time(NULL);
#endif
} else if (ac == 2 && zend_get_parameters_ex(2, &filename,
&filetime) != FAILURE) {
[..]
have a look at the part with HAVE_UTIME_NULL. if HAVE_UTIME_NULL is
*not* defined, it will be initialized with time(NULL). But if it is
defined, newtime->modtime and newtime->actime will be
*uninitialized*!!! There's no code to initialize both values with
something like 0 or NULL. The struct newtime is on the stack and has
random content!
HAVE_UTIME_NULL seems to be defined on my system and so touch() sets
random values for modtime and actime.
Greetings from Germany,
Stefan Briesenick
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=17159&edit=1