Hi Peter,

and thanks for your swift reply.

I tried changing the foreign type of len from int to integer and size_t,
but unfortunately neither had any impact.

Note that the signature of SHA1Update function is size_t, so the foreign
binding should probably be set to size_t too regardless of not fixing this
problem or not.

K.

On Sun, Jun 2, 2019 at 1:01 PM Peter Bex <pe...@more-magic.net> wrote:

> On Sun, Jun 02, 2019 at 12:39:25PM +0200, Kristian Lein-Mathisen wrote:
> > Hi guys,
> >
> > I've come across a strange problem with simple-sha1. Sometimes it reports
> > the wrong hash for large files when I use the sha1sum procedure. I don't
> > know if the problem is there for strings.
> >
> > 1216 klm@kth ~/archive  ➤ csi -R simple-sha1 -p '(sha1sum
> "MOV_0384.mp4")'
> > ; sha1sum "MOV_0384.mp4"
> > cb491b2f692dc3e9269a633f54eceb85269b0442
> > 3b673158654ddc9bb668b5eafc050c8be66ad968
> >  ./xz2/dcim/phone/100ANDRO/MOV_0384.mp4
> >
> > >From not-very-rigorous testing, it seems it happens on all files that
> are
> > bigger than the 512M mark:
>
> This just screams "overflow"; (integer-length (* 512 1024 1024) => 30
>
> Are you using CHICKEN 4 or CHICKEN 5?
>
> Even CHICKEN 4 should deal with this correctly by overflowing into a
> flonum.  That would be a bug in the egg, then.
>
> Perhaps the fix is changing:
> (define update (foreign-lambda void "SHA1Update" c-pointer c-pointer int))
> into:
> (define update (foreign-lambda void "SHA1Update" c-pointer c-pointer
> integer))
>
> Can you try?
>
> Cheers,
> Peter
>
_______________________________________________
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers

Reply via email to