GNU bug report logs - #55952
[PATCH] bindat (strz): Write null terminator after variable length string

Previous Next

Package: emacs;

Reported by: Richard Hansen <rhansen <at> rhansen.org>

Date: Mon, 13 Jun 2022 21:49:01 UTC

Severity: normal

Tags: patch

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Richard Hansen <rhansen <at> rhansen.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 55952 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca
Subject: bug#55952: [PATCH] bindat (strz): Write null terminator after variable length string
Date: Tue, 14 Jun 2022 16:47:47 -0400
[Message part 1 (text/plain, inline)]
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
[OpenPGP_signature (application/pgp-signature, attachment)]

This bug report was last modified 3 years and 35 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.