mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 06:20:55 -08:00
bindat (strz): Write null terminator after variable length string
* lisp/emacs-lisp/bindat.el (bindat--pack-strz): Explicitly write a null byte after packing a variable-length string to ensure proper termination when packing to a pre-allocated string. * doc/lispref/processes.texi (Bindat Types): Update documentation. * test/lisp/emacs-lisp/bindat-tests.el (bindat-test--str-strz-prealloc): Update tests.
This commit is contained in:
parent
dcee64d4bf
commit
6c3b6149d9
3 changed files with 9 additions and 15 deletions
|
|
@ -450,6 +450,9 @@ e.g. corresponding to STRUCT.FIELD1[INDEX2].FIELD3..."
|
|||
;; need to scan the input string looking for a null byte.
|
||||
(error "Null byte encountered in input strz string"))
|
||||
(aset bindat-raw (+ bindat-idx i) (aref v i)))
|
||||
;; Explicitly write a null terminator in case the user provided a
|
||||
;; pre-allocated string to bindat-pack that wasn't zeroed first.
|
||||
(aset bindat-raw (+ bindat-idx len) 0)
|
||||
(setq bindat-idx (+ bindat-idx len 1))))
|
||||
|
||||
(defun bindat--pack-bits (len v)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue