From: [EMAIL PROTECTED]
Operating system: linux, kernel 2.4.18
PHP version: 4.2.0
PHP Bug Type: Reproducible crash
Bug description: touch() is broken
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 bug report at http://bugs.php.net/?id=17159&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=17159&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=17159&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=17159&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=17159&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=17159&r=support
Expected behavior: http://bugs.php.net/fix.php?id=17159&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=17159&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=17159&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=17159&r=globals