Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Relative stream possible issue with pointers #147

Open
Xerkus opened this issue Feb 26, 2016 · 1 comment
Open

Relative stream possible issue with pointers #147

Xerkus opened this issue Feb 26, 2016 · 1 comment

Comments

@Xerkus
Copy link
Member

Xerkus commented Feb 26, 2016

I was looking through stream implementation. Relative stream and the stream it wraps are sharing same pointer, right?
So if we rewind wrapped stream, read on relative will return data before offset position.
Also tell() will give negative position, which is out of bounds error.

This shared pointer in streams looks extremely bug prone to me.

May be on seekable streams we should store pointer locally, set it before performing operation and record new position after doing it?

As simplified example:

public function read()
{
    $this->seek($this->position, SEEK_SET);
    $result = fread($resource, $length);
    $this->position = $this->tell();
    return $result;
}
@Xerkus Xerkus changed the title Relative stream possible issue Relative stream possible issue with pointers Feb 26, 2016
@weierophinney
Copy link
Member

This repository has been closed and moved to laminas/laminas-diactoros; a new issue has been opened at laminas/laminas-diactoros#27.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants