libsoup r1221 - in trunk: . libsoup



Author: danw
Date: Tue Dec  9 19:53:49 2008
New Revision: 1221
URL: http://svn.gnome.org/viewvc/libsoup?rev=1221&view=rev

Log:
	* libsoup/soup-uri.c (soup_uri_new): Explicitly document the fact
	that you have to call soup_uri_set_path() when using
	soup_uri_new(NULL), since path is required to be non-%NULL.

	* libsoup/soup-connection.c (connect_message): initialize
	uri->path

	* libsoup/soup-cookie.c (soup_cookie_applies_to_uri):
	g_return_val_if_fail() rather than crashing if uri->path is %NULL.
	Also, fix the cookie/uri path comparison to not potentially read
	off the end of uri->path. #562191, Mark Lee.


Modified:
   trunk/ChangeLog
   trunk/libsoup/soup-connection.c
   trunk/libsoup/soup-cookie.c
   trunk/libsoup/soup-uri.c

Modified: trunk/libsoup/soup-connection.c
==============================================================================
--- trunk/libsoup/soup-connection.c	(original)
+++ trunk/libsoup/soup-connection.c	Tue Dec  9 19:53:49 2008
@@ -418,6 +418,7 @@
 	soup_uri_set_scheme (uri, SOUP_URI_SCHEME_HTTPS);
 	soup_uri_set_host (uri, soup_address_get_name (priv->server_addr));
 	soup_uri_set_port (uri, soup_address_get_port (priv->server_addr));
+	soup_uri_set_path (uri, "");
 	msg = soup_message_new_from_uri (SOUP_METHOD_CONNECT, uri);
 	soup_uri_free (uri);
 

Modified: trunk/libsoup/soup-cookie.c
==============================================================================
--- trunk/libsoup/soup-cookie.c	(original)
+++ trunk/libsoup/soup-cookie.c	Tue Dec  9 19:53:49 2008
@@ -916,16 +916,21 @@
 	if (cookie->expires && soup_date_is_past (cookie->expires))
 		return FALSE;
 
+	/* uri->path is required to be non-NULL */
+	g_return_val_if_fail (uri->path != NULL, FALSE);
+
 	/* The spec claims "/foo would match /foobar", but fortunately
 	 * no one is really that crazy.
 	 */
 	plen = strlen (cookie->path);
 	if (cookie->path[plen - 1] == '/')
 		plen--;
+	if (strncmp (cookie->path, uri->path, plen) != 0)
+		return FALSE;
 	if (uri->path[plen] && uri->path[plen] != '/')
 		return FALSE;
 
-	return !strncmp (cookie->path, uri->path, plen);
+	return TRUE;
 }
 
 gboolean

Modified: trunk/libsoup/soup-uri.c
==============================================================================
--- trunk/libsoup/soup-uri.c	(original)
+++ trunk/libsoup/soup-uri.c	Tue Dec  9 19:53:49 2008
@@ -372,7 +372,9 @@
  * Parses an absolute URI.
  *
  * You can also pass %NULL for @uri_string if you want to get back an
- * "empty" #SoupURI that you can fill in by hand.
+ * "empty" #SoupURI that you can fill in by hand. (You will need to
+ * call at least soup_uri_set_scheme() and soup_uri_set_path(), since
+ * those fields are required.)
  *
  * Return value: a #SoupURI, or %NULL.
  **/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]