summaryrefslogtreecommitdiff
path: root/test/lisp/emacs-lisp/bindat-tests.el
diff options
context:
space:
mode:
authorRichard Hansen <rhansen@rhansen.org>2022-06-13 14:32:01 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2022-06-13 15:33:12 +0200
commit86325f960af8eb1df712e2f26e2b708f80c14ac6 (patch)
tree8e13db67d9fa1bfe48e398791f752f5ddfc1a999 /test/lisp/emacs-lisp/bindat-tests.el
parent86f30c972bb421db1b8f83951ecfc15ad607fb03 (diff)
downloademacs-86325f960af8eb1df712e2f26e2b708f80c14ac6.tar.gz
emacs-86325f960af8eb1df712e2f26e2b708f80c14ac6.tar.bz2
emacs-86325f960af8eb1df712e2f26e2b708f80c14ac6.zip
bindat (strz): Error on null byte if packing variable-length string
* lisp/emacs-lisp/bindat.el (strz): Signal an error if a null byte is encountered while packing a string to a variable-length strz field. * test/lisp/emacs-lisp/bindat-tests.el (strz): Add tests (bug#55938).
Diffstat (limited to 'test/lisp/emacs-lisp/bindat-tests.el')
-rw-r--r--test/lisp/emacs-lisp/bindat-tests.el7
1 files changed, 6 insertions, 1 deletions
diff --git a/test/lisp/emacs-lisp/bindat-tests.el b/test/lisp/emacs-lisp/bindat-tests.el
index 8bb3baa485e..7d1233ded7c 100644
--- a/test/lisp/emacs-lisp/bindat-tests.el
+++ b/test/lisp/emacs-lisp/bindat-tests.el
@@ -240,7 +240,12 @@
(ert-deftest bindat-test--strz-varlen-pack ()
(should (equal (bindat-pack spec "") "\0"))
- (should (equal (bindat-pack spec "abc") "abc\0")))
+ (should (equal (bindat-pack spec "abc") "abc\0"))
+ ;; Null bytes in the input string break unpacking.
+ (should-error (bindat-pack spec "\0"))
+ (should-error (bindat-pack spec "\0x"))
+ (should-error (bindat-pack spec "x\0"))
+ (should-error (bindat-pack spec "x\0y")))
(ert-deftest bindat-test--strz-varlen-unpack ()
(should (equal (bindat-unpack spec "\0") ""))