You need to initialize cert to either NULL or a valid pointer.
On Mar 18, 2014, at 8:21 AM, Nikita Koptelov <u...@u-net.in> wrote: > Good day, > I'm trying to use openSSL libs to parse certificate request, but something > goes wrong. > The thread throws segfault around: > > > 0x7ffff77fee0a <+0x007a> mov %r8d,%ecx > 0x7ffff77fee0d <+0x007d> mov %r13d,(%r12) > 0x7ffff77fee11 <+0x0081> callq 0x7ffff77fe000 <CRYPTO_lock@plt> > > in CRYPTO_add_lock when using d2i_X509_REQ_fp(). Could anyone help me with > the problem? > > Code: > FILE* fp; > FILE* fperr; > > fp = fopen(path,"r"); > if (fp != NULL) > { > fperr = fopen("/home/utrk/err","w"); > X509_REQ *cert; > d2i_X509_REQ_fp(fp,&cert); > if (!d2i_X509_REQ_fp(fp,&cert)) > { > ERR_print_errors_fp(fperr); > } > fclose(fp); > fclose(fperr); > } > > > > Full backtrace: http://pastebin.com/q5JkX3fh > > Best wishes, > Nick