mainGnuTLS - Support: sr #107729, certtool --generate-request...

 
 

sr #107729: certtool --generate-request crashes when generating key on-the-fly

Submitter:  Petr Pisar <petrp>
Submitted:  Wed 29 Jun 2011 07:36:17 PM UTC
   
 
Category:  Included programs Priority:  5 - Normal
Severity:  3 - Normal Status:  Done
Privacy:  Public Assigned to:  nmav
Open/Closed:  Closed Operating System:  GNU/Linux
* Mandatory Fields

Add a New Comment Rich Markup
   

Sat 23 Jul 2011 02:32:22 PM UTC, comment #2: 
Nikos Mavrogiannopoulos <nmav>
Group administrator
Wed 29 Jun 2011 08:09:00 PM UTC, comment #1: 

Attached patch should fix it.

(file #23590)

Petr Pisar <petrp>
Wed 29 Jun 2011 07:36:17 PM UTC, original submission:  

Running

$ certtool --generate-request --hash SHA256 --bits 2048 --outfile pisar-q.req

from gnutls-2.12.7 or git HEAD I get segfault:

(gdb) run
Starting program: /tmp/gnutls-devel/src/.libs/certtool --generate-request --hash SHA256 --bits 2048 --outfile pisar-q.req
[Thread debugging using libthread_db enabled]
Generating a PKCS #10 certificate request...
** Note: Please use the --sec-param instead of --bits
Generating a 2048 bit RSA private key...

Program received signal SIGSEGV, Segmentation fault.
0xb7f46e34 in check_if_clean (key=0x0) at gnutls_privkey.c:296
296       if (key->type != 0)
(gdb) bt
#0  0xb7f46e34 in check_if_clean (key=0x0) at gnutls_privkey.c:296
#1  0xb7f46e65 in gnutls_privkey_import_x509 (pkey=0x0, key=0x8080e00, flags=1)
    at gnutls_privkey.c:363
#2  0x08050849 in generate_request (cinfo=0xbfffeaf8) at certtool.c:1843
#3  0x0804ed86 in gaa_parser (argc=8, argv=0xbfffebe4) at certtool.c:1128
#4  0x0804c88d in main (argc=8, argv=0xbfffebe4) at certtool.c:102

As you can see NULL pointer `key' is dereferenced at gnutls_privkey.c:296.

Apparently, the key is not initialized properly. The `key' is `pkey' from certtol.c:1830:

  ret = gnutls_privkey_init (&pkey);
  if (ret < 0)
    error (EXIT_FAILURE, 0, "privkey_init: %s", gnutls_strerror (ret));

  /* Load the private key.
   */

  pkey = load_private_key (0, cinfo);
  if (!pkey)
    {
      xkey = generate_private_key_int ();

      print_private_key (xkey);

      ret = gnutls_privkey_import_x509(pkey, xkey, GNUTLS_PRIVKEY_IMPORT_AUTO_RELEASE);

Or first two arguments of gnutls_privkey_import_x509() should be pointers.

Petr Pisar <petrp>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #23590:  0001-Fix-private-key-initialization-when-generating-reque.patch added by petrp (1KiB - application/octet-stream - Proposed fix)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by nmav (Posted a comment)
  • -email is unavailable- added by petrp (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-07-23 nmav Open/ClosedOpen Closed
    2011-07-23 nmav StatusNone Done
        Assigned toNone nmav
    2011-06-29 petrp Attached File- Added 0001-Fix-private-key-initialization-when-generating-reque.patch, #23590

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code