wininet: Fix an off-by-one error in InternetCreateUrlW.
Fix an off-by-one error in the size of buffer used to store the port number in InternetCreateUrlW.
This commit is contained in:
parent
b0fcaf9d48
commit
e4adc07333
|
@ -3786,7 +3786,7 @@ static BOOL calc_url_length(LPURL_COMPONENTSW lpUrlComponents,
|
||||||
|
|
||||||
if (!url_uses_default_port(nScheme, lpUrlComponents->nPort))
|
if (!url_uses_default_port(nScheme, lpUrlComponents->nPort))
|
||||||
{
|
{
|
||||||
char szPort[MAX_WORD_DIGITS];
|
char szPort[MAX_WORD_DIGITS+1];
|
||||||
|
|
||||||
sprintf(szPort, "%d", lpUrlComponents->nPort);
|
sprintf(szPort, "%d", lpUrlComponents->nPort);
|
||||||
*lpdwUrlLength += strlen(szPort);
|
*lpdwUrlLength += strlen(szPort);
|
||||||
|
@ -4021,7 +4021,7 @@ BOOL WINAPI InternetCreateUrlW(LPURL_COMPONENTSW lpUrlComponents, DWORD dwFlags,
|
||||||
|
|
||||||
if (!url_uses_default_port(nScheme, lpUrlComponents->nPort))
|
if (!url_uses_default_port(nScheme, lpUrlComponents->nPort))
|
||||||
{
|
{
|
||||||
WCHAR szPort[MAX_WORD_DIGITS];
|
WCHAR szPort[MAX_WORD_DIGITS+1];
|
||||||
|
|
||||||
sprintfW(szPort, percentD, lpUrlComponents->nPort);
|
sprintfW(szPort, percentD, lpUrlComponents->nPort);
|
||||||
*lpszUrl = ':';
|
*lpszUrl = ':';
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
#define CREATE_URL9 "about:blank"
|
#define CREATE_URL9 "about:blank"
|
||||||
#define CREATE_URL10 "about://host/blank"
|
#define CREATE_URL10 "about://host/blank"
|
||||||
#define CREATE_URL11 "about:"
|
#define CREATE_URL11 "about:"
|
||||||
|
#define CREATE_URL12 "http://www.winehq.org:65535"
|
||||||
|
|
||||||
static HANDLE hCompleteEvent;
|
static HANDLE hCompleteEvent;
|
||||||
|
|
||||||
|
@ -1140,7 +1141,6 @@ static void InternetCreateUrlA_test(void)
|
||||||
urlComp.nPort = 8080;
|
urlComp.nPort = 8080;
|
||||||
urlComp.lpszScheme = "about";
|
urlComp.lpszScheme = "about";
|
||||||
len = strlen(CREATE_URL11);
|
len = strlen(CREATE_URL11);
|
||||||
len++; /* work around bug in native wininet */
|
|
||||||
szUrl = (char *)HeapAlloc(GetProcessHeap(), 0, ++len);
|
szUrl = (char *)HeapAlloc(GetProcessHeap(), 0, ++len);
|
||||||
ret = InternetCreateUrlA(&urlComp, ICU_ESCAPE, szUrl, &len);
|
ret = InternetCreateUrlA(&urlComp, ICU_ESCAPE, szUrl, &len);
|
||||||
ok(ret, "Expected success\n");
|
ok(ret, "Expected success\n");
|
||||||
|
@ -1148,6 +1148,23 @@ static void InternetCreateUrlA_test(void)
|
||||||
ok(!strcmp(szUrl, CREATE_URL11), "Expected %s, got %s\n", CREATE_URL11, szUrl);
|
ok(!strcmp(szUrl, CREATE_URL11), "Expected %s, got %s\n", CREATE_URL11, szUrl);
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, szUrl);
|
HeapFree(GetProcessHeap(), 0, szUrl);
|
||||||
|
|
||||||
|
memset(&urlComp, 0, sizeof(urlComp));
|
||||||
|
urlComp.dwStructSize = sizeof(URL_COMPONENTS);
|
||||||
|
urlComp.lpszScheme = "http";
|
||||||
|
urlComp.dwSchemeLength = 0;
|
||||||
|
urlComp.nScheme = INTERNET_SCHEME_HTTP;
|
||||||
|
urlComp.lpszHostName = "www.winehq.org";
|
||||||
|
urlComp.dwHostNameLength = 0;
|
||||||
|
urlComp.nPort = 65535;
|
||||||
|
len = strlen(CREATE_URL12);
|
||||||
|
szUrl = (char *)HeapAlloc(GetProcessHeap(), 0, ++len);
|
||||||
|
ret = InternetCreateUrlA(&urlComp, ICU_ESCAPE, szUrl, &len);
|
||||||
|
ok(ret, "Expected success\n");
|
||||||
|
ok(len == strlen(CREATE_URL12), "Expected len %d, got %ld\n", strlen(CREATE_URL12), len);
|
||||||
|
ok(!strcmp(szUrl, CREATE_URL12), "Expected %s, got %s\n", CREATE_URL12, szUrl);
|
||||||
|
|
||||||
|
HeapFree(GetProcessHeap(), 0, szUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void HttpSendRequestEx_test(void)
|
static void HttpSendRequestEx_test(void)
|
||||||
|
|
Loading…
Reference in New Issue