Module rwutil::bytes0 [] [src]

Read and write 0-terminated byte strings.

Example:

use rwutil::bytes0::ReadBytes0Ext;

// a &[u8] implements the io::Read interface
let src: Vec<u8> = vec![0x61, 0x62, 0x63, 0];

// reading data into a new vector
let buf: Vec<u8> = src.as_slice().read_bytes0().unwrap();

assert_eq!(buf, b"abc")

Security

The current implementation is similar to the trouble gets from C in that it does not have a maximum size for reading. While you will not encounter a buffer overflow, the vector the string is read into can grow arbitrarily large, allow a supplier of untrusted data to cause an OOM panic if allowed to send an infinite amount of data.

Traits

ReadBytes0Ext
WriteBytes0Ext