Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relative stream possible issue with pointers #27

Open
weierophinney opened this issue Dec 31, 2019 · 0 comments
Open

Relative stream possible issue with pointers #27

weierophinney opened this issue Dec 31, 2019 · 0 comments

Comments

@weierophinney
Copy link
Member

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;
}

Originally posted by @Xerkus at zendframework/zend-diactoros#147

@Xerkus Xerkus added Bug Something isn't working and removed Bug Something isn't working labels May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants