On Thu, Nov 09, 2006, Peter Waltenberg wrote: > " > Please tell me how the compiler knows what type 'x' > should be passed as. If > you pass a pointer to a function as 'd2i' whose first type is not defined > as > a 'char **', you get undefined behavior -- how can the compiler possibly > use > the correct type's passing rules when it thinks the function takes a 'char > **' and it actuall takes an 'X509 **'. > " > x is still just a pointer to data - so it's the same length in any case, > all pointers to lvalues are the same length in C. The only issue there is > whether it's aligned correctly - that's the programmers problem. > > Mixing something like char *(*d2i)(), and char ** IS problematic, since > those aren't guaranteed to be the same length but as far as I can remember > OpenSSL doesn't do that. > > ret=d2i(x,&p,len); > > d2i is a function (prototype is unknown) > but I've been told x is a pointer, &p is a pointer, len is long. There's > nothing indeterminate about the size of any of those. > > C isn't a strongly typed language - there's no language requirement for an > accurate function prototype or that the types of the arguments be correct > - only that the size of them is correct. > > C is not the same language as C++, this instance should work with a C > compiler - whether or not the compiler is passing the arguments via the > stack or in registers. >
The d2i() case BTW can be replaced in most cases by an equivalent which uses ASN1_ITEM which doesn't have this problem. There are a few ASN1_ITEM replacements for some functions but nothing for PEM (yet). 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 Development Mailing List openssl-dev@openssl.org Automated List Manager [EMAIL PROTECTED]