helpGnuTLS - Support: sr #108563, API functions with output...

 
 

sr #108563: API functions with output arguments should allow null values

Submitted by:  Eduardo Lima <elima>
Submitted on:  Tue 06 May 2014 08:57:44 AM UTC  
 
Category: Core libraryPriority: 5 - Normal
Severity: 3 - NormalStatus: Need Info
Privacy: PublicAssigned to: None
Open/Closed: OpenOperating System: None

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Mon 12 May 2014 08:52:34 AM UTC, comment #4:

Thanks for checking that, a patch would be nice.

Nikos Mavrogiannopoulos <nmav>
Project Administrator
Mon 12 May 2014 08:06:58 AM UTC, comment #3:

Looking at the upstream repo I notice that there are other export methods that do not check nullness of out args: gnutls_pubkey_export_rsa_raw, gnutls_pubkey_export_dsa_raw, gnutls_dh_params_export_raw, and possibly others; so this issue is still valid.

I can provide patches for these methods if needed.

Eduardo Lima <elima>
Mon 12 May 2014 07:48:42 AM UTC, comment #2:

> To which version of gnutls does your comment refer to?


My comment refers to version 3.2.13 from Debian jessie. Didn't check upstream though, my bad.

> The latest version allows for null parameters in the function that you mention.


Great!

> In any case it is quite simple to provide a patch to improve documentation or fix the functions that you're interested to.


Agree, though it is normally a good idea to wait for feedback before start working in a patch, this case being a good example :).

Thank you and cheers

Eduardo Lima <elima>
Sat 10 May 2014 08:48:42 AM UTC, comment #1:

Hello,
To which version of gnutls does your comment refer to? The latest version allows for null parameters in the function that you mention. In any case it is quite simple to provide a patch to improve documentation or fix the functions that you're interested to.

Nikos Mavrogiannopoulos <nmav>
Project Administrator
Tue 06 May 2014 08:57:44 AM UTC, original submission:

The "export" family of functions in GnuTLS API expect non-null values for their gnutls_datum_t out arguments (e.g gnutls_x509_privkey_export_rsa_raw()), otherwise it crashes without checking. This is dangerous and non-efficient at the same time:

Dangerous because it is (arguably) a common practice in API with out arguments to pass NULL for values that are not of interest. Also, such expectation is not documented or asserted internaly.

Non-efficient because API users wanting to retrieve just a particular parameter would have to pass valid pointers to all arguments, which then will be allocated by GnuTLS, only to be freed immediately.

My suggestion is to change the behavior of these functions so that out arguments for which a NULL argument was passed are not allocated and simply ignored.
Or, at least, change the documentation to cleary state that non-NULL values are expected, and add sentinels internally to avoid the crashes.

Eduardo Lima <elima>

 

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

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follows 1 latest change.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 10 May 2014 08:48:42 AM UTCnmavStatusNone=>Need Info

    Back to the top


    Powered by Savane 3.1-cleanup