Bug #76995 [NEW]: fseek() breaks reading in read/append (a+) mode

From: Date: Wed, 10 Oct 2018 14:58:09 +0000
Subject: Bug #76995 [NEW]: fseek() breaks reading in read/append (a+) mode
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217508@lists.php.net to get a copy of this message
From:             miloslav dot hula at gmail dot com
Operating system: 
PHP version:      7.3.0RC2
Package:          Streams related
Bug Type:         Bug
Bug description:fseek() breaks reading in read/append (a+) mode

Description:
------------
URL in a test script shows, how fseek() in 'a+' mode breaks contents
reading.

Documentation of fopen() says, that fseek() is OK, but documentation of
fseek() says, that seeking in a+ mode is bad idea.

In documentation of fopen():

a+ - Open for reading and writing; place the file pointer at the end of
the file. If the file does not exist, attempt to create it. In this
mode, fseek() only affects the reading position, writes are always
appended.

In documentation of fseek():

If you have opened the file in append (a or a+) mode, any data you write
to the file will always be appended, regardless of the file position,
and the result of calling fseek() will be undefined.

Test script:
---------------
https://3v4l.org/gTXsR


-- 
Edit bug report at https://bugs.php.net/bug.php?id=76995&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=76995&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=76995&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=76995&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=76995&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=76995&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=76995&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=76995&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=76995&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=76995&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=76995&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=76995&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=76995&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=76995&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76995&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=76995&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=76995&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=76995&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76995&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=76995&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=76995&r=mysqlcfg



Thread (5 messages)

« previous php.bugs (#217508) next »