On Tue, Jul 13, 2004, El hallabi-Kettani Abderrahmane wrote:

> I have a seg fault with PKCS7, the system don't
> recognise this structure
> 
> fp = fopen("binary_file", "rb");
> 
>       if(fp)
>       {
>               fseek(fp, 0, SEEK_END) ;
>               nSize = ftell(fp);
>               printf("%d\n",nSize);
>               fseek(fp, 0, SEEK_SET);
>               pData=(char *) malloc(sizeof(char)*nSize);
>               fread(pData, sizeof(char), nSize, fp);
>               pBio = BIO_new(BIO_s_mem());
>               //BIO_write(pBio, pData, nSize);
>               BIO_read_filename(pBio,pData);
>               p7=d2i_PKCS7_bio(pBio,NULL);
> ------------->        printf("%d\n", p7->detached);
> 
> here the problem , anything in the strcture of PKCS7
> that i can test it drive me to the same segfault.
> 
> Abdou,
> 
> thank for your help. 
> 
> 

You don't need to call d2i_PKCS7_bio() in that convoluted manner. You can just
call d2i_PKCS7_fp() on the FILE pointer without the fseek/fread before hand.

You might however want to try:

openssl pkcs7 -inform DER -in file.der

first to see if OpenSSL things it is a valid PKCS#7 file.

Steve.
--
Dr Stephen N. Henson. Email, S/MIME and PGP keys: see homepage
OpenSSL project core developer and freelance consultant.
Funding needed! Details on homepage.
Homepage: http://www.drh-consultancy.demon.co.uk
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to