From e1e28eeec4619359322227478d826e3dcdd0a09d Mon Sep 17 00:00:00 2001 From: John Hodge Date: Mon, 18 Feb 2013 23:50:16 +0800 Subject: [PATCH] Usermode/liburi - Fixed off-by-one in path code --- Usermode/Libraries/liburi.so_src/main.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Usermode/Libraries/liburi.so_src/main.c b/Usermode/Libraries/liburi.so_src/main.c index e8f8dea0..a9f2e175 100644 --- a/Usermode/Libraries/liburi.so_src/main.c +++ b/Usermode/Libraries/liburi.so_src/main.c @@ -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; } -- 2.20.1