[glib] networkaddress: Fix userinfo parsing in uris



commit 5632e9fc9cc588d4846cb40e88194d025f758412
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Apr 8 10:15:29 2012 -0400

    networkaddress: Fix userinfo parsing in uris
    
    The code that is checking the userinfo part was accidentally
    given a pointer to the end of the userinfo, so it was not
    checking the right portion of the string at all.

 gio/gnetworkaddress.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/gio/gnetworkaddress.c b/gio/gnetworkaddress.c
index e158a40..cbb272d 100644
--- a/gio/gnetworkaddress.c
+++ b/gio/gnetworkaddress.c
@@ -475,15 +475,15 @@ _g_uri_parse_authority (const char  *uri,
     return FALSE;
 
   start += 2;
-  p = strchr (start, '@');
 
-  if (p != NULL)
+  if (strchr (start, '@') != NULL)
     {
       /* Decode userinfo:
        * userinfo      = *( unreserved / pct-encoded / sub-delims / ":" )
        * unreserved    = ALPHA / DIGIT / "-" / "." / "_" / "~"
        * pct-encoded   = "%" HEXDIG HEXDIG
        */
+      p = start;
       while (1)
 	{
 	  c = *p++;
@@ -504,7 +504,7 @@ _g_uri_parse_authority (const char  *uri,
 	    }
 
 	  /* unreserved /  sub-delims / : */
-	  if (!(g_ascii_isalnum(c) ||
+	  if (!(g_ascii_isalnum (c) ||
 		strchr (G_URI_OTHER_UNRESERVED, c) ||
 		strchr (G_URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS, c) ||
 		c == ':'))
@@ -540,7 +540,7 @@ _g_uri_parse_authority (const char  *uri,
 	    break;
 
 	  /* unreserved /  sub-delims */
-	  if (!(g_ascii_isalnum(c) ||
+	  if (!(g_ascii_isalnum (c) ||
 		strchr (G_URI_OTHER_UNRESERVED, c) ||
 		strchr (G_URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS, c) ||
 		c == ':' ||
@@ -574,7 +574,7 @@ _g_uri_parse_authority (const char  *uri,
 	    }
 
 	  /* unreserved /  sub-delims */
-	  if (!(g_ascii_isalnum(c) ||
+	  if (!(g_ascii_isalnum (c) ||
 		strchr (G_URI_OTHER_UNRESERVED, c) ||
 		strchr (G_URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS, c)))
 	    goto error;



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