Bug #18006: php cannot overwrite exsiting data in file

From: Date: Thu, 27 Jun 2002 01:06:47 +0000
Subject: Bug #18006: php cannot overwrite exsiting data in file
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-12188@lists.php.net to get a copy of this message
From: ilia@prohost.org Operating system: Linux 2.4.18 PHP version: 4.2.1 PHP Bug Type: Scripting Engine problem Bug description: php cannot overwrite exsiting data in file When doing the following in php, the result is a file that is 200 bytes, 100 bytes of NULL and 100 bytes of the actual data. <?php $fp = fopen('a', 'a+'); $s=ftell($fp); ftruncate($fp, $s+100); fwrite($fp, str_repeat('1', 100)); fclose($fp); ?> In reality there should be a 100 byte file, full of 1s. However, this example works <?php $fp = fopen('a', 'a+'); $s=ftell($fp); ftruncate($fp, $s+100, SEEK_SET); fseek($fp, $s, SEEK_SET); fwrite($fp, str_repeat('1', 100)); fclose($fp); ?> -- Edit bug report at http://bugs.php.net/?id=18006&edit=1 -- Fixed in CVS: http://bugs.php.net/fix.php?id=18006&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=18006&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=18006&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=18006&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=18006&r=support Expected behavior: http://bugs.php.net/fix.php?id=18006&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=18006&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=18006&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=18006&r=globals

« previous php.bugs (#12188) next »