GNU bug report logs - #55938
[PATCH] bindat (strz): Error on null byte if packing variable-length string

Previous Next

Package: emacs;

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

Date: Mon, 13 Jun 2022 05:49:02 UTC

Severity: normal

Tags: patch

Fixed in version 29.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #13 received at 55938 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Richard Hansen <rhansen <at> rhansen.org>
Cc: 55938 <at> debbugs.gnu.org
Subject: Re: bug#55938: [PATCH] bindat (strz): Error on null byte if packing
 variable-length string
Date: Mon, 13 Jun 2022 09:12:20 -0400
>    (let* ((v (string-to-unibyte v))
>           (len (length v)))
>      (dotimes (i len)
> +      (if (= (aref v i) 0)
> +          ;; Alternatively we could pretend that this was the end of
> +          ;; the string and stop packing, but then bindat-length would
> +          ;; need to scan the input string looking for a null byte.
> +          (error "Null byte encountered in input strz string"))

I suspect a `string-match` looking for NUL would be faster.


        Stefan





This bug report was last modified 2 years and 347 days ago.

Previous Next


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