GNOME Bugzilla – Bug 620220
soup_uri_set_query_from_form segfaults when given hash containing a null value
Last modified: 2010-11-09 17:30:41 UTC
def handleAnnounceRedirect(serv : Soup.Server, mesg : Soup.Message, path : string, query : GLib.HashTable?, client : Soup.ClientContext) var location = new Soup.URI("http://localhost/announce") if query is not null location.set_query_from_form(query) var redirect = location.to_string(true) mesg.set_status(KnownStatusCode.MOVED_PERMANENTLY) mesg.response_headers.append("Location", redirect) When the above code is provided the following URL, it causes a segfault: "http://localhost/announce.php?a"
+ Trace 222181
This does not happen when given "http://localhost/announce.php?a=". While checking each value of a hash before passing it to soup_uri_set_query_from_form would solve this, it would be much cleaner (and proper) to test for null in soup_form_encode_hash's foreach callback.
The following fix has been pushed: 82b4522 Fix parsing/generation of URI queries that aren't HTML forms
Created attachment 174147 [details] [review] Fix parsing/generation of URI queries that aren't HTML forms soup_form_decode() used to accept strings that weren't "name=value" pairs, but soup_form_encode_hash() would crash if you passed the resulting GHashTable to it. Fix both sides: now soup_form_decode() ignores non-"name=value" elements, and soup_form_encode_hash() g_return_if_fail()s rather than crashing. Also fix use of deprecated soup-form.h method names in soup-uri.c and soup-server.c