Skip to content

Encoder can possibly send duplicate bytes #12

@akhilles

Description

@akhilles

Hello, I was reading through the Encoder's AsyncRead impl:

async-sse/src/encoder.rs

Lines 40 to 52 in 50db988

// Write the current buffer to completion.
let local_buf = self.buf.as_mut().unwrap();
let local_len = local_buf.len();
let max = buf.len().min(local_buf.len());
buf[..max].clone_from_slice(&local_buf[..max]);
self.cursor += max;
// Reset values if we're done reading.
if self.cursor == local_len {
self.buf = None;
self.cursor = 0;
};

I noticed that self.cursor wasn't being used to slice local_buf. So, it might be possible to copy the same section of local_buf multiple times.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions