]> git.proxmox.com Git - mirror_qemu.git/blobdiff - util/uri.c
all: Remove unnecessary glib.h includes
[mirror_qemu.git] / util / uri.c
index b9a7b546bf9f110868b386d2b7ed6f0b79f0695c..70a9cbcbd2f12b694ece103779b9b2f6eb0a1f78 100644 (file)
@@ -51,9 +51,7 @@
  *
  */
 
-#include <glib.h>
-#include <string.h>
-#include <stdio.h>
+#include "qemu/osdep.h"
 
 #include "qemu/uri.h"
 
@@ -320,19 +318,23 @@ static int
 rfc3986_parse_port(URI *uri, const char **str)
 {
     const char *cur = *str;
+    int port = 0;
 
     if (ISA_DIGIT(cur)) {
-       if (uri != NULL)
-           uri->port = 0;
-       while (ISA_DIGIT(cur)) {
-           if (uri != NULL)
-               uri->port = uri->port * 10 + (*cur - '0');
-           cur++;
-       }
-       *str = cur;
-       return(0);
+        while (ISA_DIGIT(cur)) {
+            port = port * 10 + (*cur - '0');
+            if (port > 65535) {
+                return 1;
+            }
+            cur++;
+        }
+        if (uri) {
+            uri->port = port;
+        }
+        *str = cur;
+        return 0;
     }
-    return(1);
+    return 1;
 }
 
 /**
@@ -1935,7 +1937,8 @@ uri_resolve_relative (const char *uri, const char * base)
        val = g_strdup (uri);
        goto done;
     }
-    if (!strcmp(bas->path, ref->path)) {
+    if (bas->path == ref->path ||
+        (bas->path && ref->path && !strcmp(bas->path, ref->path))) {
        val = g_strdup("");
        goto done;
     }