From c58759647c8fc28996c6d519f2a38497c7edb704 Mon Sep 17 00:00:00 2001 From: Nikodemus Siivola Date: Thu, 19 Apr 2012 22:37:08 +0300 Subject: [PATCH] sanitize one of the recent c-string decoding tests No out-of-bounds accesses, thanks! ...and thanks to Nathan who spotted my bogosity. --- tests/alien.impure.lisp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/alien.impure.lisp b/tests/alien.impure.lisp index aa6eee6..98e88f2 100644 --- a/tests/alien.impure.lisp +++ b/tests/alien.impure.lisp @@ -348,7 +348,13 @@ (assert (eq :multibyte-4 (handler-case - (let ((c-string (coerce #(70 111 246 0) + ;; KLUDGE, sort of. + ;; + ;; C-STRING decoding doesn't know how long the string is, and since this + ;; looks like a 4-byte sequence, it will grab 4 octets off the end. + ;; + ;; So we pad the vector for safety's sake. + (let ((c-string (coerce #(70 111 246 0 0 0) '(vector (unsigned-byte 8))))) (sb-sys:with-pinned-objects (c-string) (sb-alien::c-string-to-string (sb-sys:vector-sap c-string) -- 1.7.10.4