Usermode/liburi - Fixed off-by-one in path code
authorJohn Hodge <[email protected]>
Mon, 18 Feb 2013 15:50:16 +0000 (23:50 +0800)
committerJohn Hodge <[email protected]>
Mon, 18 Feb 2013 15:50:16 +0000 (23:50 +0800)
Usermode/Libraries/liburi.so_src/main.c

index e8f8dea..a9f2e17 100644 (file)
@@ -63,7 +63,7 @@ tURI *URI_Parse(const char *String)
        {
                 int    hostlen, portlen, pathlen;
                tmp += 3;       // Eat '://'
-               ret = malloc(sizeof(tURI) + strlen(String) - 2);
+               ret = malloc(sizeof(tURI) + protolen + 1 + strlen(tmp) + 1);
                
                ret->Proto = (char*)ret + sizeof(tURI);
                memcpy(ret->Proto, String, protolen);
@@ -140,14 +140,8 @@ tURI *URI_Parse(const char *String)
                else
                        ret->Path = ret->Host + hostlen + 1;
                
-               tmp ++;
                pathlen = 0;
-               while(*tmp)
-               {
-                       ret->Path[pathlen] = *tmp;
-                       tmp ++;
-                       pathlen ++;
-               }
+               strcpy(ret->Path, tmp);
                
                return ret;
        }

UCC git Repository :: git.ucc.asn.au