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 743070 - avoid NULL dereference
avoid NULL dereference
Status: RESOLVED FIXED
Product: gssdp
Classification: Other
Component: General
0.14.x
Other All
: Normal normal
: ---
Assigned To: GUPnP Maintainers
GUPnP Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-01-17 09:34 UTC by Thomas Klausner
Modified: 2019-02-22 09:29 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch fixing the problem. (503 bytes, patch)
2015-01-17 09:34 UTC, Thomas Klausner
committed Details | Review

Description Thomas Klausner 2015-01-17 09:34:21 UTC
Created attachment 294728 [details] [review]
Patch fixing the problem.

In gssdp-0.14.11, tools/gssdp-device-sniffer.c:resource_available_cb splits a string into tokens, and then splits the second token again, if it exists:

        usn_tokens = g_strsplit (usn, "::", -1);
        g_assert (usn_tokens != NULL && usn_tokens[0] != NULL);

        uuid = usn_tokens[0] + 5; /* skip the prefix 'uuid:' */

        if (usn_tokens[1]) {
                char **urn_tokens;

                urn_tokens = g_strsplit (usn_tokens[1], ":device:", -1);
                        
                if (urn_tokens[1])
                        device_type = g_strdup (urn_tokens[1]);
                g_strfreev (urn_tokens);
        }



However, it does not check if the second token (usn_tokens[1]) has length zero, in which case g_strsplit would return an empty vector (i.e., NULL) according to https://developer.gnome.org/glib/stable/glib-String-Utility-Functions.html#g-strsplit, which makes urn_tokens[1] de-reference NULL.

Just checking the length of usn_tokens[1] before entering this case solves the problem, see attached patch.
Comment 1 Jens Georg 2015-01-19 08:07:21 UTC
Review of attachment 294728 [details] [review]:

+1