[openssl-users] ECDSA_SIG_new and ECDSA_SIG_free details - NULL vs zeros

Ken Goldman kgoldman at us.ibm.com
Wed Jan 11 16:28:48 UTC 2017


On 1/11/2017 10:32 AM, Stephan Mühlstrasser wrote:
>>
>> OpenSSL does not support platforms where the memory representation of the
>> NULL pointer contains non-zero bytes. IIRC there are even tests for this.
>
> Could someone from the OpenSSL team please explain the rationale for
> this decision? What is the problem with using assignments with 0 or NULL
> to initialize pointers?

I suspect that it was a shortcut, where they used memset() on an entire 
structure, and it hopefully set pointers to NULL.

What I pointed out is that if NULL is not all zeros, this breaks.

~~~  BTW ~~~

Compilers know this.  So

	char *ptr = NULL;

and

	char *ptr = 0;

are equivalent, even on platforms where NULL is not all zeros.

It's when you cast the ptr to an integer first that it fails.




More information about the openssl-users mailing list