From e439bb5fdd48fb9558e4ea29623689d15ec7c3dd Mon Sep 17 00:00:00 2001 From: "Tarn W. Burton" Date: Fri, 10 May 2024 06:38:21 -0400 Subject: [PATCH] Add test for buffer overun in encoding buffer --- src/tests/normal-tests/mixed.lsp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/tests/normal-tests/mixed.lsp b/src/tests/normal-tests/mixed.lsp index 956d192fc..eff6b1634 100644 --- a/src/tests/normal-tests/mixed.lsp +++ b/src/tests/normal-tests/mixed.lsp @@ -561,3 +561,19 @@ (is (equal (multiple-value-list (read-line (make-instance 'character-input-stream :value "a "))) '("a" nil)))) + +;;;; Author: Tarn W. Burton +;;;; Created: 2024-05-19 +;;;; Description: +;;;; Test to ensure that write-char returns the correct value. An +;;;; incorrect value or stack smashing indicated a buffer overrun +;;;; caused by an encoding buffer that is too small. + +(test mix.0030.write-char-encode-buffer + (is (equal (with-open-file (s "/tmp/whatever.txt" + :if-does-not-exist :create + :if-exists :supersede + :external-format :ucs-4 + :direction :output) + (write-char #\a s)) + #\a)))