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 706805 - libgrlnet mock data facility's ignored-parameters feature crashes for queries without parameters.
libgrlnet mock data facility's ignored-parameters feature crashes for queries...
Status: RESOLVED FIXED
Product: grilo
Classification: Other
Component: core
0.2.x
Other Linux
: Normal normal
: ---
Assigned To: grilo-maint
grilo-maint
Depends on:
Blocks:
 
 
Reported: 2013-08-26 14:28 UTC by James Henstridge
Modified: 2013-09-08 12:01 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
net: Check if URL has query parameters (1.65 KB, patch)
2013-09-08 11:59 UTC, Juan A. Suarez Romero
committed Details | Review

Description James Henstridge 2013-08-26 14:28:10 UTC
I was trying to use Grilo's mock data feature in a test, and found that my test started segfaulting:

  • #0 get_url_mocked
    at grl-net-mock.c line 68
  • #1 get_url_cb
    at grl-net-wc.c line 314
  • #2 g_main_dispatch
    at /build/buildd/glib2.0-2.37.5/./glib/gmain.c line 3065
  • #3 g_main_context_dispatch
    at /build/buildd/glib2.0-2.37.5/./glib/gmain.c line 3641
  • #4 g_main_context_iterate
    at /build/buildd/glib2.0-2.37.5/./glib/gmain.c line 3712
  • #5 g_main_loop_run
    at /build/buildd/glib2.0-2.37.5/./glib/gmain.c line 3906

The mock data configuration file used the ignored-parameters, but the URL in question had no query parameters.  The problem code is:

  if (ignored_parameters) {
    SoupURI *uri = soup_uri_new (url);
    char *new_query = g_regex_replace (ignored_parameters,
                                       soup_uri_get_query (uri), -1, 0,
                                       "", 0, NULL);
    soup_uri_set_query (uri, *new_query ? new_query : NULL);
    new_url = soup_uri_to_string (uri, FALSE);
    soup_uri_free (uri);
  } else {
    new_url = g_strdup (url);
  }

soup_uri_get_query() returns NULL, triggering a g_return_if_fail() assertion in g_regex_replace.  This leads to new_query being set to NULL, leading to a segfault when it is dereferenced in the next statement.

The parameter rewriting should only occur if the URI actually has parameters.
Comment 1 Juan A. Suarez Romero 2013-09-08 11:59:26 UTC
Created attachment 254393 [details] [review]
net: Check if URL has query parameters

When using the GrlNet mock, we could need to skip some of the query
parameters in the URL.

This commit cover the case of having an URL without any query parameter.
Comment 2 Juan A. Suarez Romero 2013-09-08 12:01:25 UTC
Attachment 254393 [details] pushed as 2ae4708 - net: Check if URL has query parameters

commit 2ae4708a521d550376169cf2dde37636a02599d1
Author: Juan A. Suarez Romero <jasuarez@igalia.com>
Date:   Sun Sep 8 13:57:53 2013 +0200

    net: Check if URL has query parameters
    
    When using the GrlNet mock, we could need to skip some of the query
    parameters in the URL.
    
    This commit cover the case of having an URL without any query parameter.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=706805

 libs/net/grl-net-mock.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)