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 766638 - ahc: fix possible NULL deref
ahc: fix possible NULL deref
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other Linux
: Normal minor
: 1.8.2
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-05-18 23:32 UTC by Martin Kelly
Modified: 2016-05-25 08:09 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
ahc: fix possible NULL deref (1.38 KB, patch)
2016-05-18 23:32 UTC, Martin Kelly
none Details | Review
v2-0001-ahc-fix-potential-NULL-deref.patch (1.87 KB, patch)
2016-05-19 19:28 UTC, Martin Kelly
committed Details | Review

Description Martin Kelly 2016-05-18 23:32:03 UTC
This bug was found via cppcheck static analysis.

If android.hardware.Camera.getParameters returns NULL, then object will
be NULL, and we won't allocate params. This means that the GST_DEBUG
statement referencing params->object will be invalid. Fix this by
logging only if params has been allocated.
Comment 1 Martin Kelly 2016-05-18 23:32:34 UTC
Created attachment 328163 [details] [review]
ahc: fix possible NULL deref
Comment 2 Wonchul Lee 2016-05-19 01:40:35 UTC
now I got why you added https://bugzilla.gnome.org/show_bug.cgi?id=766637.
I think it would be better something like,

if (!object) {
  GST_WARNING ("android.hardware.Camera.getParameter is NULL");
  return NULL;
}

params = g_slice_new0 (GstAHCParameters);
params->object = gst_amc_jni_object_ref (env, object);
....

instead of checking the object is not null.
Comment 3 Sebastian Dröge (slomo) 2016-05-19 08:05:41 UTC
Comment on attachment 328163 [details] [review]
ahc: fix possible NULL deref

That suggestion seems a bit cleaner indeed
Comment 4 Martin Kelly 2016-05-19 19:28:15 UTC
Created attachment 328224 [details] [review]
v2-0001-ahc-fix-potential-NULL-deref.patch
Comment 5 Martin Kelly 2016-05-19 19:28:36 UTC
I agree with the suggestion, and my attached v2 patch implements it.
Comment 6 Sebastian Dröge (slomo) 2016-05-20 06:16:56 UTC
commit 8c236a9f2e681fa4756a9781b35fc53c1380cf61
Author: Martin Kelly <martin@surround.io>
Date:   Thu May 19 09:25:57 2016 -0700

    ahc: fix potential NULL deref
    
    This bug was found via cppcheck static analysis.
    
    If android.hardware.Camera.getParameters returns NULL, then object will
    be NULL, and we won't allocate params. This means that the GST_DEBUG
    statement referencing params->object will be invalid. Fix this by
    exiting early if android.hardware.Camera.getParameters returns NULL.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=766638