After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 719545 - gcr-trust: Fix a potential NULL pointer dereference
gcr-trust: Fix a potential NULL pointer dereference
Status: RESOLVED FIXED
Product: gcr
Classification: Core
Component: General
unspecified
Other All
: Normal normal
: ---
Assigned To: GNOME keyring maintainer(s)
GNOME keyring maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2013-11-29 12:08 UTC by Philip Withnall
Modified: 2019-02-22 11:58 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gcr-trust: Fix a potential NULL pointer dereference (790 bytes, patch)
2013-11-29 12:08 UTC, Philip Withnall
none Details | Review
gcr-trust: Fix a potential NULL pointer dereference (2.72 KB, patch)
2013-12-02 11:46 UTC, Philip Withnall
committed Details | Review

Description Philip Withnall 2013-11-29 12:08:03 UTC
Found by scan-build.
Comment 1 Philip Withnall 2013-11-29 12:08:05 UTC
Created attachment 263110 [details] [review]
gcr-trust: Fix a potential NULL pointer dereference

If error is NULL, this will crash.

Found by scan-build.
Comment 2 Christian Persch 2013-11-30 13:08:56 UTC
This function's error handling doesn't look right to me, wit or without the patch. perform_add_pinned_certificate() is called from a public function, gcr_trust_add_pinned_certificate() and thus error might be NULL.  

GError *lerr = NULL;
[...]
       /* We need an error below */
        if (error && !*error)
                *error = lerr;
[...]
        object = gck_enumerator_next (en, cancellable, error);
[...]
        if (*error)
                return FALSE;
(or with your patch, if (error && *error))

However, if error == NULL, then we still need to return here if gck_enumator_next() failed. 

So really this function should use lerr, and propagate to @error on failures.
Comment 3 Philip Withnall 2013-12-02 11:46:41 UTC
Created attachment 263296 [details] [review]
gcr-trust: Fix a potential NULL pointer dereference

The error handling in perform_add_pinned_certificate() didn’t allow for
error to be NULL, but it could easily have been NULL since
perform_add_pinned_certificate() is called from public functions with
GError arguments.

Rework the error handling to use a local GError and propagate it to the
caller. This should prevent crashes if error is NULL.

Found by scan-build.
Comment 4 Stef Walter 2013-12-02 13:11:46 UTC
Thanks.

Attachment 263296 [details] pushed as decba1e - gcr-trust: Fix a potential NULL pointer dereference