xach / zs3

Work with Amazon S3 and Amazon CloudFront from Common Lisp
http://www.xach.com/lisp/zs3/
Other
38 stars 16 forks source link

put-vector fails for non-simple arrays #27

Open avodonosov opened 7 years ago

avodonosov commented 7 years ago

On quicklisp 2017-02-27 and CCL we observe this failure, caused by ironclad:digest-sequence:

This is somethihg new, on elder quicklisps this error didn't happen.


The value #(31 139 8 0 0 0 0 0 4 3 211 8 113 13 14 209 117 15
            242 116 209 117 113 12 113 180 10 114 245 245 15 115
            213 5 139 6 133 250 5 43 104 88 249 120 58 233 134
            251 7 249 184 40 40 21 150 102 38 103 231 100 22 23
            40 24 25 24 154 233 26 88 234 26 89 42 105 106 2 0
            213 208 117 68 69 0 0
            0) is not of the expected type IRONCLAD::SIMPLE-OCTET-VECTOR.
   [Condition of type TYPE-ERROR]

Restarts:
 0: [STORE-VALUE] Assign a new value of type SIMPLE-OCTET-VECTOR to SEQUENCE
 1: [RETRY] Retry SLIME interactive evaluation request.
 2: [*ABORT] Return to SLIME's top level.
 3: [ABORT-BREAK] Reset this thread
 4: [ABORT] Kill this thread

Backtrace:
  0: (#<STANDARD-METHOD IRONCLAD:UPDATE-DIGEST (IRONCLAD:MD5 VECTOR)> #S(IRONCLAD:MD5 :AMOUNT 0 :BUFFER #(0 0 0 0 0 0 ...) :BUFFER-INDEX ...) #(31 139 8 0 0 0 ...) :START 0 :END 86)
  1: (#<STANDARD-METHOD IRONCLAD:DIGEST-SEQUENCE (T T)> #S(IRONCLAD:MD5 :AMOUNT 0 :BUFFER #(0 0 0 0 0 0 ...) :BUFFER-INDEX ...) #(31 139 8 0 0 0 ...) :START 0 :END NIL :DIGEST NIL :DIGEST-START 0)
  2: (CCL::%%CHECK-KEYWORDS #(2 #(:DIGEST-START :DIGEST :END :START) #<CCL:METHOD-FUNCTION IRONCLAD:DIGEST-SEQUENCE (T T)>) 17580451205682)
  3: (NIL #<Unknown Arguments>)
  4: (ZS3::VECTOR-MD5/B64 #(31 139 8 0 0 0 ...))
  5: (#<STANDARD-METHOD SLOT-UNBOUND (T ZS3::REQUEST (EQL ZS3::CONTENT-MD5))> #<STANDARD-CLASS ZS3::REQUEST> #<ZS3::REQUEST #x302119F5958D> ZS3::CONTENT-MD5)
  6: (NIL #<Unknown Arguments>)
  7: ((:INTERNAL CCL::%XERR-DISP))
  8: (CCL::FUNCALL-WITH-ERROR-REENTRY-DETECTION #<CCL:COMPILED-LEXICAL-CLOSURE (:INTERNAL CCL::%XERR-DISP) #x7FEA2442DBDF>)
  9: (CCL::%XERR-DISP 17580388607978)
 10: (CCL::%PASCAL-FUNCTIONS% 2 17580388607978)
 11: (NIL #<Unknown Arguments>)
 12: (CCL::%MAYBE-STD-SLOT-VALUE-USING-CLASS #<STANDARD-CLASS ZS3::REQUEST> #<ZS3::REQUEST #x302119E3DC6D> #<STANDARD-EFFECTIVE-SLOT-DEFINITION for instance slot ZS3::CONTENT-MD5 #x3020020EA57D>)
 13: (#<STANDARD-METHOD INITIALIZE-INSTANCE :AFTER (ZS3::REQUEST)> #<STANDARD-EFFECTIVE-SLOT-DEFINITION for instance slot ZS3::CONTENT-MD5 #x3020020EA57D> :METHOD :PUT :BUCKET "cl-test-grid" :KEY "main-201..
 14: (CCL::%%BEFORE-AND-AFTER-COMBINED-METHOD-DCODE (NIL #<STANDARD-METHOD INITIALIZE-INSTANCE :AFTER (ZS3::REQUEST)> . 17580451205788))
 15: (CCL::%%STANDARD-COMBINED-METHOD-DCODE (NIL (#<STANDARD-METHOD INITIALIZE-INSTANCE :AFTER (ZS3::REQUEST)>) #<CCL::STANDARD-KERNEL-METHOD INITIALIZE-INSTANCE (STANDARD-OBJECT)>) 17580451205788)
 16: (NIL #<Unknown Arguments>)
 17: (CCL::%MAKE-STD-INSTANCE #<STANDARD-CLASS ZS3::REQUEST> (:METHOD :PUT :BUCKET "cl-test-grid" :KEY "main-20170401215233.R3N" ...))
 18: (#<CCL::STANDARD-KERNEL-METHOD MAKE-INSTANCE (STANDARD-CLASS)> #<STANDARD-CLASS ZS3::REQUEST> :METHOD :PUT :BUCKET "cl-test-grid" :KEY "main-20170401215233.R3N" :METADATA NIL :AMZ-HEADERS (("acl" ..))..
 19: (CCL::%MAKE-INSTANCE #<CLASS-CELL for ZS3::REQUEST #x3020020E1C2D> :METHOD :PUT :BUCKET "cl-test-grid" :KEY "main-20170401215233.R3N" :METADATA NIL :AMZ-HEADERS (("acl" . "private")) :EXTRA-HTTP-HEADE..
 20: (ZS3:PUT-OBJECT #(31 139 8 0 0 0 ...) "cl-test-grid" "main-20170401215233.R3N" :ACCESS-POLICY :PRIVATE :PUBLIC NIL :METADATA NIL :STRING-EXTERNAL-FORMAT :UTF-8 :CACHE-CONTROL NIL :CONTENT-ENCODING "gz..
 21: (ZS3:PUT-VECTOR #(31 139 8 0 0 0 ...) "cl-test-grid" "main-20170401215233.R3N" :START NIL :END NIL :ACCESS-POLICY :PRIVATE :PUBLIC NIL :METADATA NIL :CACHE-CONTROL NIL :CONTENT-ENCODING "gzip" :CONTEN..
avodonosov commented 7 years ago

This fix in crypto.lisp will work if https://github.com/froydnj/ironclad/pull/84 acceped

(defun vector-md5/b64 (vector)
  (base64:usb8-array-to-base64-string
   ;; Ironclad accepts non-simple arrays ohly on SBCL and CMUCL,
   ;; according to the ironclad:digest-sequence docstring and code
   #+(or sbcl cmu)
   (ironclad:digest-sequence :md5 vector)
   #-(or sbcl cmu)
   (if (typep vector '(simple-array (unsigned-byte 8) (*)))
       (ironclad:digest-sequence :md5 vector)
       (ironclad:digest-stream :md5 (flexi-streams:make-in-memory-input-stream vector)))))