diff options
author | Richard Hansen <rhansen@rhansen.org> | 2022-06-09 20:41:50 -0400 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2022-06-16 09:55:49 +0300 |
commit | 6c3b6149d9e7c882729634dc5a7e647daeecfdf3 (patch) | |
tree | 5690c2fcaec05edda7a42d4cbe6edc9fca1b7fe8 /test/lisp/emacs-lisp/bindat-tests.el | |
parent | dcee64d4bf2751a6b67716e2e43267d9e73640cd (diff) | |
download | emacs-6c3b6149d9e7c882729634dc5a7e647daeecfdf3.tar.gz emacs-6c3b6149d9e7c882729634dc5a7e647daeecfdf3.tar.bz2 emacs-6c3b6149d9e7c882729634dc5a7e647daeecfdf3.zip |
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.
Diffstat (limited to 'test/lisp/emacs-lisp/bindat-tests.el')
-rw-r--r-- | test/lisp/emacs-lisp/bindat-tests.el | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/test/lisp/emacs-lisp/bindat-tests.el b/test/lisp/emacs-lisp/bindat-tests.el index 7d1233ded7c..cc223ad14e2 100644 --- a/test/lisp/emacs-lisp/bindat-tests.el +++ b/test/lisp/emacs-lisp/bindat-tests.el @@ -182,8 +182,8 @@ ((((x strz 2)) ((x . "a"))) . "ax") ((((x strz 2)) ((x . "ab"))) . "ab") ((((x strz 2)) ((x . "abc"))) . "ab") - ((,(bindat-type strz) "") . "xx") - ((,(bindat-type strz) "a") . "ax"))) + ((,(bindat-type strz) "") . "\0x") + ((,(bindat-type strz) "a") . "a\0"))) (let ((prealloc (make-string 2 ?x))) (apply #'bindat-pack (append (car tc) (list prealloc))) (should (equal prealloc (cdr tc)))))) |