support count option for NullString/NullWIdeString
Hi,
NullString is useful, but I am concerned when reading malicious files that do not contain '\0'. As with Vec<u8>, support for the count option avoids reading data without limit.
Also, we sometimes store a string in a fixed-length field and fill it with '\0', but even then we want to use NullString to avoid unnecessary reads. For that use cases, please see the test I wrote in this PR.
Hi,
Sorry for the delay, this repository/crate has been replaced with binrw, so you should look there for the latest version of this library.
Glancing over this patch, it looks like it is just reimplementing the pad_size_to directive, so you should use that instead. If this is actually doing something different, please open a new PR in the binrw repository and we’ll take a look.
Best regards, and apologies again for the delay,
Hello,
Glancing over this patch, it looks like it is just reimplementing the pad_size_to directive, so you should use that instead
No, my count implementation differs from pad_size_to because pad_size_to does nothing when NullString is longer than the specified length. My count implementation ensures that it doesn't read more than the specified length (even if there is no '\0'), like n of strncpy.
But first, I'll check the binrw, thank you 😄