Skip to content

Vec<u8> impl needs attention #4

@kymikoloco

Description

@kymikoloco

Now that we've got some more uds wrangling under our belts, I noticed my WireFormat impl of the Vec<u8> should probably not read until the end, it's test code at best and should not be exposed, or at least the implementation should be more robust

impl WireFormat for Vec<u8> {
    fn option_from_reader<T: std::io::Read>(reader: &mut T) -> Result<Option<Self>, Error> {
        let mut data = Vec::new();
 // This should not read to end
        reader.read_to_end(&mut data)?;
        Ok(Some(data))
    }

    fn required_size(&self) -> usize {
        self.len()
    }

    fn to_writer<T: std::io::Write>(&self, writer: &mut T) -> Result<usize, Error> {
        writer.write_all(self)?;
        Ok(self.len())
    }
}

impl SingleValueWireFormat for Vec<u8> {}
impl IterableWireFormat for Vec<u8> {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions