On 6/14/22 08:52, Eli Zaretskii wrote: > Thanks, but AFAICT the documentation doesn't describe accurately > enough what the modified code does: what if the pre-allocated > destination string doesn't have enough storage for the null byte the > code adds? The existing code advances the index for the terminator, it just doesn't write 0 to that byte. So the existing code already signals an error in that case unless the `strz` is the final field. Regardless, the documentation for `bindat-pack` [1] clearly states that the pre-allocated string must have enough room: > When pre-allocating, you should make sure `(length raw)` meets or > exceeds the total length to avoid an out-of-range error. [1] https://www.gnu.org/software/emacs/manual/html_node/elisp/Bindat-Functions.html#index-bindat_002dpack