From 3dfb0b9be42ef4ec71af8ac51d864d3a4b2979b0 Mon Sep 17 00:00:00 2001 From: "Pierre R. Mai" Date: Mon, 15 Oct 2012 01:46:12 +0200 Subject: [PATCH] Incorporate fix for partial updates ending on rest boundaries from sbcl. In all previous versions, if an update-md5-state call received a sequence which exactly filled a partially filled buffer, then that buffer block was ignored and the agregate data not updated. --- md5.lisp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/md5.lisp b/md5.lisp index 6bf04b6..5ac5a16 100644 --- a/md5.lisp +++ b/md5.lisp @@ -404,11 +404,15 @@ bounded by start and end, which must be numeric bounding-indices." (declare (type (integer 0 63) amount)) (copy-to-buffer sequence start amount buffer buffer-index) (setq start (the fixnum (+ start amount))) - (when (>= start end) - (setf (md5-state-buffer-index state) (+ buffer-index amount)) - (return-from update-md5-state state))) - (fill-block-ub8 block buffer 0) - (update-md5-block regs block)) + (let ((new-index (+ buffer-index amount))) + (when (= new-index 64) + (fill-block-ub8 block buffer 0) + (update-md5-block regs block) + (setq new-index 0)) + (when (>= start end) + (setf (md5-state-buffer-index state) new-index) + (incf (md5-state-amount state) length) + (return-from update-md5-state state))))) ;; Handle main-part and new-rest (etypecase sequence ((simple-array (unsigned-byte 8) (*))