<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.3.2">
</HEAD>
<BODY>
<PRE>
While working on implementing Elephant on top of CL-SQL, which
led me to do base64 encoding of the serialized lisp objects, I discovered
what I suspect to be a (normally) unexercised bug in buffer-read-byte,
namely that it currently uses ":char" instead of :unsigned-byte.
This bug goes unnoticed because the serializer only puts values less than
128 into the position that it reads with this routine. I discovered it
because I am using this routine to read out the whole buffer-stream into
a byte-vector for the purpose of base64 encoding so that I can put it into
a text field in PostGres safely.
If you make this change, all of the tests still run exactly as they did.
(defun buffer-read-byte (bs)
"Read a byte."
(declare (optimize (speed 3) (safety 0))
(type buffer-stream bs))
(let ((position (buffer-stream-position bs)))
(incf (buffer-stream-position bs))
(deref-array (buffer-stream-buffer bs) '(:array <U><B>:unsigned-byte</B></U>) position)))
@@ -733,7 +736,33 @@
(type buffer-stream bs))
(let ((position (buffer-stream-position bs)))
(incf (buffer-stream-position bs))
- (deref-array (buffer-stream-buffer bs) '(:array :char) position)))
+ (deref-array (buffer-stream-buffer bs) '(:array :unsigned-byte) position)))
</PRE>
</BODY>
</HTML>