FedericoCeratto / nim-libsodium

Nim wrapper for the libsodium library
Mozilla Public License 2.0
46 stars 13 forks source link

Error with r a n d o m b y t e s / r a n d o m b y t e s . c #8

Closed Serasar closed 5 years ago

Serasar commented 5 years ago

Have this program:

var key = randombytes(crypto_secretbox_KEYBYTES())
let c = crypto_secretbox_easy(key, "test")
let d = crypto_secretbox_easy(key, c)
echo(d)

Get this error: A s s e r t i o n f a i l e d !

P r o g r a m : C : \ D e v \ n i m _ e n c \ c r y p t o . e x e F i l e : r a n d o m b y t e s / r a n d o m b y t e s . c , L i n e 2 0 4

E x p r e s s i o n : b u f l e n < = S I Z E M A X

This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. SIGABRT: Abnormal termination.

Serasar commented 5 years ago

It seems that this error only happens on 32 bit install for some reason. Everything works fine on 64 bits.

Serasar commented 5 years ago

https://github.com/jedisct1/libsodium/issues/733#issuecomment-405032890

buf_len is an unsigned long long in the C code but a csize (=size_t) in the Nim wrapper.

FedericoCeratto commented 5 years ago

Fixed in the new release. Tested on a 32bit chroot. Thank you @Serasar