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

winpty-agent reads beyond end of input queue #94

Closed
melak47 opened this issue Oct 19, 2016 · 1 comment
Closed

winpty-agent reads beyond end of input queue #94

melak47 opened this issue Oct 19, 2016 · 1 comment

Comments

@melak47
Copy link

melak47 commented Oct 19, 2016

In winpty/src/agent/NamedPipe.cc, there is this function:

size_t NamedPipe::peek(void *data, size_t size)
{
    ASSERT(m_openMode & OpenMode::Reading);
    const auto out = reinterpret_cast<char*>(data);
    const size_t ret = std::min(size, m_inQueue.size());
    std::copy(&m_inQueue[0], &m_inQueue[size], out);
    return ret;
}

Shouldn't &m_inQueue[size] be &m_inQueue[ret] instead?
I noticed this thanks to MSVC's debug iterators complaining (m_inQueue.size() was 0, but size was 8).

@rprichard
Copy link
Owner

I think you're right about that. You can submit a PR if you'd like, or I'll fix it tonight probably.

Thanks for the report.

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