jturner314 / ndarray-npy

.npy and .npz file format support for ndarray
https://docs.rs/ndarray-npy
Apache License 2.0
56 stars 18 forks source link

Add validity checks when reading bools #8

Closed jturner314 closed 5 years ago

jturner314 commented 5 years ago

This adds checks for invalid values when reading an array of bools (see #7). This is necessary to avoid undefined behavior in the case of corrupted or malicious input.

Instead of returning an error on values other than 0x00 or 0x01, we could interpret other values as true (i.e. overwrite them with 0x01). For the time being, I prefer the more conservative approach of returning an error, but if anyone has a reason to allow values other than 0x00 or 0x01, feel free to create an issue.