[elephant-devel] Suspected bug in sleepycat.lisp file

Robert L. Read read at robertlread.net
Mon Sep 19 16:21:27 UTC 2005


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 :unsigned-byte) 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)))

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/elephant-devel/attachments/20050919/7830ac17/attachment.html>


More information about the elephant-devel mailing list