Bug 118902

Summary: [patch] wrong signatures in d2i_RSAPublicKey man pages
Product: Documentation Reporter: Pietro Cerutti <gahr>
Component: Books & ArticlesAssignee: freebsd-doc (Nobody) <doc>
Status: Closed FIXED    
Severity: Affects Only Me CC: simon
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
_d2i_RSAPublicKey.3.diff none

Description Pietro Cerutti 2007-12-20 20:40:00 UTC

the signatures for the following functions:

 d2i_RSAPublicKey
 d2i_RSA_PUBKEY
 d2i_RSAPrivateKey
 d2i_Netscape_RSA

are wrong in our man pages.
They all specify the second argument as

unsigned char **

where it should actually be 

const unsigned char **

Please have a look at the definition of d2i_RSA_PUBKEY at

crypto/openssl/crypto/asn1/x_pubkey.c:416

and consider the program below:

> cat d2i_test.c
#include <openssl/rsa.h>
#include <openssl/x509.h>

int main(void)
{
   RSA *rsa;
   const unsigned char *const_p;
   unsigned char *p;

   /*
    * Using unsigned char, as per MAN page
    */
   rsa = d2i_RSAPublicKey(NULL, &p, 0L);              /* :13   */
   rsa = d2i_RSA_PUBKEY(NULL, &p, 0L);                /* :14   */
   rsa = d2i_RSAPrivateKey(NULL, &p, 0L);             /* :15   */
   rsa = d2i_Netscape_RSA(NULL, &p, 0L, NULL);        /* :16   */

   /*
    * Using const unsigned char
    */
   rsa = d2i_RSAPublicKey(NULL, &const_p, 0L);        /* :21   */
   rsa = d2i_RSA_PUBKEY(NULL, &const_p, 0L);          /* :22   */
   rsa = d2i_RSAPrivateKey(NULL, &const_p, 0L);       /* :23   */
   rsa = d2i_Netscape_RSA(NULL, &const_p, 0L, NULL);  /* :24   */

   return (0);
}

> gcc -Wall -lssl d2i_test.c 
d2i_test.c: In function 'main':
d2i_test.c:13: warning: passing argument 2 of 'd2i_RSAPublicKey' from incompatible pointer type
d2i_test.c:14: warning: passing argument 2 of 'd2i_RSA_PUBKEY' from incompatible pointer type
d2i_test.c:15: warning: passing argument 2 of 'd2i_RSAPrivateKey' from incompatible pointer type
d2i_test.c:16: warning: passing argument 2 of 'd2i_Netscape_RSA' from incompatible pointer type


The patch below fixes the man pages and the files under /usr/src using these functions.
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2007-12-21 07:12:03 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-doc

Reclassify.
Comment 2 simon 2007-12-21 16:33:24 UTC
On 2007.12.20 21:30:34 +0100, Pietro Cerutti wrote:

> the signatures for the following functions:
> 
>  d2i_RSAPublicKey
>  d2i_RSA_PUBKEY
>  d2i_RSAPrivateKey
>  d2i_Netscape_RSA
> 
> are wrong in our man pages.

[...]

The manual pages are actually generated from the upstream POD
documentation (openssl/doc/crypto/d2i_RSAPublicKey.pod) so the changes
need to be made to the POD files.  Otherwise they will simply vanish
after next import.

Any chance you could submit the changes directly to the OpenSSL
project [1]?  Then we would get the fixes when the next version of
OpenSSL is imported.

Does the source changes fix actual bugs or is it just style/warning?
If they don't fix real bugs I would prefer for them also to go via
OpenSSL to not divert from upstream more than needed.

[1] http://www.openssl.org/support/rt.html

-- 
Simon L. Nielsen
Comment 3 Pietro Cerutti 2007-12-21 16:52:53 UTC
Simon L. Nielsen wrote:
> On 2007.12.20 21:30:34 +0100, Pietro Cerutti wrote:
> 
>> the signatures for the following functions:
>>
>>  d2i_RSAPublicKey
>>  d2i_RSA_PUBKEY
>>  d2i_RSAPrivateKey
>>  d2i_Netscape_RSA
>>
>> are wrong in our man pages.
> 
> [...]
> 
> The manual pages are actually generated from the upstream POD
> documentation (openssl/doc/crypto/d2i_RSAPublicKey.pod) so the changes
> need to be made to the POD files.  Otherwise they will simply vanish
> after next import.

Please look at [2] for a patch to the POD file.
> 
> Any chance you could submit the changes directly to the OpenSSL
> project [1]?  Then we would get the fixes when the next version of
> OpenSSL is imported.

I've already CC'ed openssl-dev on the original PR submit.
I will fill a bug report on their Request Tracker.

> 
> Does the source changes fix actual bugs or is it just style/warning?
> If they don't fix real bugs I would prefer for them also to go via
> OpenSSL to not divert from upstream more than needed.

The last one in the .diff file adds const'ness to a variable
declaration, which I find quite important.
The other ones simply remove useless casts.

[2] http://www.gahr.ch/FreeBSD/patches/118902_d2i_RSAPublicKey.pod.diff

-- 
Pietro Cerutti

PGP Public Key:
http://gahr.ch/pgp
Comment 4 Pietro Cerutti freebsd_committer freebsd_triage 2012-10-19 10:45:23 UTC
State Changed
From-To: open->closed

This was fixed upstream: 
http://rt.openssl.org/Ticket/Display.html?id=1626