From 9736644ed50f996091afe16243c3fa4a373498a0 Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Mon, 15 Jun 2015 17:32:50 +0200 Subject: [PATCH] winhttp: Correctly handle relative redirect paths. --- dlls/winhttp/request.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c index 2fee2c3f20e..5aa90e46dd2 100644 --- a/dlls/winhttp/request.c +++ b/dlls/winhttp/request.c @@ -2296,13 +2296,21 @@ static BOOL handle_redirect( request_t *request, DWORD status ) { WCHAR *path, *p; - len = strlenW( location ) + 1; - if (location[0] != '/') len++; - if (!(p = path = heap_alloc( len * sizeof(WCHAR) ))) goto end; - - if (location[0] != '/') *p++ = '/'; - strcpyW( p, location ); - + if (location[0] == '/') + { + len = strlenW( location ); + if (!(path = heap_alloc( (len + 1) * sizeof(WCHAR) ))) goto end; + strcpyW( path, location ); + } + else + { + if ((p = strrchrW( request->path, '/' ))) *p = 0; + len = strlenW( request->path ) + 1 + strlenW( location ); + if (!(path = heap_alloc( (len + 1) * sizeof(WCHAR) ))) goto end; + strcpyW( path, request->path ); + strcatW( path, slashW ); + strcatW( path, location ); + } heap_free( request->path ); request->path = path;