#18984 [NEW]: fread() add slashes on the content randomly

From: Date: Tue, 20 Aug 2002 12:58:45 +0000
Subject: #18984 [NEW]: fread() add slashes on the content randomly
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-17290@lists.php.net to get a copy of this message
From: dams@php.net Operating system: Linux debian 2 PHP version: 4.1.2 PHP Bug Type: Filesystem function related Bug description: fread() add slashes on the content randomly Hi, on my PHP 4.1.2, fread() adds randomly a addslashes() when reading a binary file. Here is the code : <?php $fp=fopen($fichier,"r"); $attendu = filesize($fichier); $attachmentorig=fread($fp,$attendu); $lu = strlen($attachmentorig); print "awaited : $attendu<BR>\n"; print "read : $lu<BR>\n"; fclose($fp); ?> basically, it reads the file (I used any JPG picture as test), and then it happens sometimes (rather unusually) that the read size is about 10% bigger than the original file size. The increase in size is always the same, when it happens. With further testing, I finally managed to find that, if the returned string is bigger than the original file size, then applying stripslashes() will solve the trouble. I tested this also on 4.2.2 (macosx) and fresh 4.3.0-dev, and no trouble seems to be reproducable, so it may be a solved trouble. It may be a 4.1.2 specific trouble. I hope this post will help anyone facing this trouble, or point some real bug. -- Edit bug report at http://bugs.php.net/?id=18984&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=18984&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=18984&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=18984&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=18984&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=18984&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=18984&r=support Expected behavior: http://bugs.php.net/fix.php?id=18984&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=18984&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=18984&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=18984&r=globals

« previous php.bugs (#17290) next »