bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#55952: [PATCH] bindat (strz): Write null terminator after variable l


From: Richard Hansen
Subject: bug#55952: [PATCH] bindat (strz): Write null terminator after variable length string
Date: Tue, 14 Jun 2022 16:47:47 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1

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

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]