Newbie question - gcry_sexp_build Seg. Fault

António Pinto pinto.antonio at gmail.com
Thu Nov 4 18:20:55 CET 2004


That was one of the attempts I've made to resolve the seg. fault. The
actual code is the following:

------------------
int buildSig(int msgid, int leaderid, char * sig) {
gcry_sexp_t plain, sign;
int len,data;
	
	data=msgid+leaderid;
	gcry_sexp_build (&plain, NULL, "(data (flags raw) (value %d))", data);
	gcry_pk_sign(&sign, plain, sKey);
	len=gcry_sexp_sprint(sign, GCRYSEXP_FMT_ADVANCED, sig, sizeof(char)*1024);

return len;
}
--------------------

And I keep getting de seg. fault.
One thing I've noticied is that the seg. fault only happens on the
first run (of the first forked process, in a multi process
enviroment).

thx

On Fri, 5 Nov 2004 01:17:43 +0000 (Local time zone must be set--see
zic manual page), t.fromm at dresearch.de <t.fromm at dresearch.de> wrote:
> 
> On Thu, 4 Nov 2004, António Pinto wrote:
> 
> > I'm getting a seg. fault while running the following code:
> >
> > ------------------------
> >       gcry_sexp_build (&plain, NULL, "(data (flags raw) (value %d))", &data); /* SEG FAULT */
> 
> Typo here: you want to use tha value of (int) data, not the value at the
> address this (uninitialised) int points to. Try '...lue %d))", data);' .
> 
> Regards,
> Thilo
> 
> /* Dipl.-Ing. (FH) Thilo Fromm, MSc., Hardware & Software
>  * DResearch Digital Media Systems GmbH
>  * Otto-Schmirgal-Str. 3, 10319 Berlin, Germany
>  * Tel: +49 (30) 515932-228  mailto:t.fromm at dresearch.de
>  * Fax: +49 (30) 515932-299      http://www.dresearch.de */
> 
> 


-- 
António Pinto



More information about the Gcrypt-devel mailing list