the following code executes once, and does fine. Calling the function a
second time gives a segfault during the call marked by "-->"
unsigned char *encrypt_message(unsigned char *message, int inl, int *outl)
{
EVP_CIPHER_CTX ctx;
EVP_CIPHER_CTX_init(&ctx);
-->EVP_EncryptInit(&ctx, EVP_bf_ecb(), NULL, NULL);
EVP_CIPHER_CTX_set_key_length(&ctx, SHA_DIGEST_LENGTH);
EVP_EncryptInit(&ctx, NULL, k, NULL);
char *ret;
int tmp, ol;
ol = 0;
ret = (char *)malloc(inl + EVP_CIPHER_CTX_block_size(&ctx));
EVP_EncryptUpdate(&ctx, &ret[ol], &tmp, message, inl);
ol = tmp;
EVP_EncryptFinal(&ctx, &ret[ol], &tmp);
*outl = ol+tmp;
return ret;
}
Anything obvious that might lead to the segfault?
Thanks,
Felix
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openss...@openssl.org
Automated List Manager majo...@openssl.org
--- Felix Dorner <feli...@web.de> wrote:
> Hi,
>=20
> the following code executes once, and does fine.
> Calling the function a
> second time gives a segfault during the call marked
> by "-->"
>=20
> unsigned char *encrypt_message(unsigned char
> *message, int inl, int *outl)
> {
> EVP_CIPHER_CTX ctx;
> EVP_CIPHER_CTX_init(&ctx);
> -->EVP_EncryptInit(&ctx, EVP_bf_ecb(), NULL,
> NULL);
> EVP_CIPHER_CTX_set_key_length(&ctx,
> SHA_DIGEST_LENGTH);
> EVP_EncryptInit(&ctx, NULL, k, NULL);
> char *ret;
> int tmp, ol;
> ol =3D 0;
> ret =3D (char *)malloc(inl +
> EVP_CIPHER_CTX_block_size(&ctx));
> EVP_EncryptUpdate(&ctx, &ret[ol], &tmp,
> message, inl);
> ol =3D tmp;
> EVP_EncryptFinal(&ctx, &ret[ol], &tmp);
> *outl =3D ol+tmp;
> return ret;
> }
>=20
>=20
> Anything obvious that might lead to the segfault?
>=20
> Thanks,
> Felix
>
______________________________________________________________________
> OpenSSL Project =20
> http://www.openssl.org
> User Support Mailing List =20
> openss...@openssl.org
> Automated List Manager =20
> majo...@openssl.org
>=20
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around=20
http://mail.yahoo.com=20
>Try calling EVP_CIPHER_CTX_cleanup(&ctx) at the end...
>
>
>
I have tried this, does not change the situation. gdb output is
200 EVP_EncryptInit(&ctx, EVP_bf_ecb(), NULL, NULL);
(gdb) step
Program received signal SIGSEGV, Segmentation fault.
0xb7df82fb in mallopt () from /lib/libc.so.6
I really dont know whats wrong here,
Felix
Felix Dorner wrote:
--
Alain Damiral
--
Matthew Clarkson
On Mon, 30 Jan 2006, Felix Dorner wrote:
> Hi,
>
> the following code executes once, and does fine. Calling the function a
> second time gives a segfault during the call marked by "-->"
>
> unsigned char *encrypt_message(unsigned char *message, int inl, int *outl)
> {
> EVP_CIPHER_CTX ctx;
> EVP_CIPHER_CTX_init(&ctx);
> -->EVP_EncryptInit(&ctx, EVP_bf_ecb(), NULL, NULL);
> EVP_CIPHER_CTX_set_key_length(&ctx, SHA_DIGEST_LENGTH);
> EVP_EncryptInit(&ctx, NULL, k, NULL);
> char *ret;
> int tmp, ol;
> ol = 0;
> ret = (char *)malloc(inl + EVP_CIPHER_CTX_block_size(&ctx));
> EVP_EncryptUpdate(&ctx, &ret[ol], &tmp, message, inl);
> ol = tmp;
> EVP_EncryptFinal(&ctx, &ret[ol], &tmp);
> *outl = ol+tmp;
> return ret;
> }
>
>
> Anything obvious that might lead to the segfault?
>
> Thanks,
thanks, felix