Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
269fe5a4
Commit
269fe5a4
authored
Sep 12, 2011
by
Thomas Mullaly
Committed by
Alexandre Julliard
Oct 10, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
urlmon: Added basic GetSecurityIdEx2 implementation.
parent
714941f8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
137 additions
and
66 deletions
+137
-66
sec_mgr.c
dlls/urlmon/sec_mgr.c
+114
-46
sec_mgr.c
dlls/urlmon/tests/sec_mgr.c
+23
-20
No files found.
dlls/urlmon/sec_mgr.c
View file @
269fe5a4
...
...
@@ -619,7 +619,7 @@ static HRESULT map_url_to_zone(LPCWSTR url, DWORD *zone, LPWSTR *ret_url)
return
hres
;
}
static
HRESULT
map_uri_to_zone
(
IUri
*
uri
,
DWORD
*
zone
)
static
HRESULT
map_uri_to_zone
(
IUri
*
uri
,
DWORD
*
zone
,
IUri
**
ret_uri
)
{
HRESULT
hres
;
IUri
*
secur_uri
;
...
...
@@ -629,7 +629,10 @@ static HRESULT map_uri_to_zone(IUri *uri, DWORD *zone)
return
hres
;
hres
=
map_security_uri_to_zone
(
secur_uri
,
zone
);
IUri_Release
(
secur_uri
);
if
(
FAILED
(
hres
)
||
!
ret_uri
)
IUri_Release
(
secur_uri
);
else
*
ret_uri
=
secur_uri
;
return
hres
;
}
...
...
@@ -708,69 +711,127 @@ static HRESULT get_action_policy(DWORD zone, DWORD action, BYTE *policy, DWORD s
return
hres
;
}
static
HRESULT
ge
t_security_id
(
LPCWSTR
url
,
BYTE
*
secid
,
DWORD
*
secid_len
)
static
HRESULT
ge
nerate_security_id
(
IUri
*
uri
,
BYTE
*
secid
,
DWORD
*
secid_len
,
DWORD
zone
)
{
LPWSTR
secur_url
,
ptr
,
ptr2
;
DWORD
zone
,
len
;
DWORD
len
;
HRESULT
hres
;
DWORD
scheme_type
;
static
const
WCHAR
wszFile
[]
=
{
'f'
,
'i'
,
'l'
,
'e'
,
':'
};
hres
=
map_url_to_zone
(
url
,
&
zone
,
&
secur_url
);
if
(
zone
==
URLZONE_INVALID
)
return
(
hres
==
0x80041001
||
hres
==
S_OK
)
?
E_INVALIDARG
:
hres
;
return
E_INVALIDARG
;
hres
=
IUri_GetScheme
(
uri
,
&
scheme_type
);
if
(
FAILED
(
hres
))
return
hres
;
/* Windows handles opaque URLs differently then hierarchical ones. */
if
(
!
is_hierarchical_scheme
(
scheme_type
)
&&
scheme_type
!=
URL_SCHEME_WILDCARD
)
{
BSTR
display_uri
;
/* file protocol is a special case */
if
(
strlenW
(
secur_url
)
>=
sizeof
(
wszFile
)
/
sizeof
(
WCHAR
)
&&
!
memcmp
(
secur_url
,
wszFile
,
sizeof
(
wszFile
)))
{
WCHAR
path
[
MAX_PATH
];
len
=
sizeof
(
path
)
/
sizeof
(
WCHAR
);
hres
=
IUri_GetDisplayUri
(
uri
,
&
display_uri
);
if
(
FAILED
(
hres
))
return
hres
;
hres
=
CoInternetParseUrl
(
secur_url
,
PARSE_PATH_FROM_URL
,
0
,
path
,
len
,
&
len
,
0
);
if
(
hres
==
S_OK
&&
!
PathIsNetworkPathW
(
path
))
{
static
const
BYTE
secidFile
[]
=
{
'f'
,
'i'
,
'l'
,
'e'
,
':'
};
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
display_uri
,
-
1
,
NULL
,
0
,
NULL
,
NULL
)
-
1
;
CoTaskMemFree
(
secur_url
);
if
(
len
+
sizeof
(
DWORD
)
>
*
secid_len
)
{
SysFreeString
(
display_uri
);
return
HRESULT_FROM_WIN32
(
ERROR_INSUFFICIENT_BUFFER
);
}
if
(
*
secid_len
<
sizeof
(
secidFile
)
+
sizeof
(
zone
))
return
HRESULT_FROM_WIN32
(
ERROR_INSUFFICIENT_BUFFER
);
WideCharToMultiByte
(
CP_ACP
,
0
,
display_uri
,
-
1
,
(
LPSTR
)
secid
,
len
,
NULL
,
NULL
);
SysFreeString
(
display_uri
);
memcpy
(
secid
,
secidFile
,
sizeof
(
secidFile
));
*
(
DWORD
*
)(
secid
+
sizeof
(
secidFile
))
=
zone
;
*
(
DWORD
*
)(
secid
+
len
)
=
zone
;
}
else
{
BSTR
host
,
scheme
;
DWORD
host_len
,
scheme_len
;
BYTE
*
ptr
;
*
secid_len
=
sizeof
(
secidFile
)
+
sizeof
(
zone
);
return
S_OK
;
hres
=
IUri_GetHost
(
uri
,
&
host
);
if
(
FAILED
(
hres
))
return
hres
;
/* The host can't be empty for Wildcard URIs. */
if
(
scheme_type
==
URL_SCHEME_WILDCARD
&&
!*
host
)
{
SysFreeString
(
host
);
return
E_INVALIDARG
;
}
}
ptr
=
strchrW
(
secur_url
,
':'
);
ptr2
=
++
ptr
;
while
(
*
ptr2
==
'/'
)
ptr2
++
;
if
(
ptr2
!=
ptr
)
memmove
(
ptr
,
ptr2
,
(
strlenW
(
ptr2
)
+
1
)
*
sizeof
(
WCHAR
));
hres
=
IUri_GetSchemeName
(
uri
,
&
scheme
);
if
(
FAILED
(
hres
))
{
SysFreeString
(
host
);
return
hres
;
}
ptr
=
strchrW
(
ptr
,
'/'
);
if
(
ptr
)
*
ptr
=
0
;
host_len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
host
,
-
1
,
NULL
,
0
,
NULL
,
NULL
)
-
1
;
scheme_len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
scheme
,
-
1
,
NULL
,
0
,
NULL
,
NULL
)
-
1
;
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
secur_url
,
-
1
,
NULL
,
0
,
NULL
,
NULL
)
-
1
;
len
=
host_len
+
scheme_len
+
sizeof
(
BYTE
)
;
if
(
len
+
sizeof
(
DWORD
)
>
*
secid_len
)
{
CoTaskMemFree
(
secur_url
);
return
HRESULT_FROM_WIN32
(
ERROR_INSUFFICIENT_BUFFER
);
}
if
(
len
+
sizeof
(
DWORD
)
>
*
secid_len
)
{
SysFreeString
(
host
);
SysFreeString
(
scheme
);
return
HRESULT_FROM_WIN32
(
ERROR_INSUFFICIENT_BUFFER
);
}
WideCharToMultiByte
(
CP_ACP
,
0
,
secur_url
,
-
1
,
(
LPSTR
)
secid
,
len
,
NULL
,
NULL
);
CoTaskMemFree
(
secur_url
);
WideCharToMultiByte
(
CP_ACP
,
0
,
scheme
,
-
1
,
(
LPSTR
)
secid
,
len
,
NULL
,
NULL
);
SysFreeString
(
scheme
);
ptr
=
secid
+
scheme_len
;
*
ptr
++
=
':'
;
WideCharToMultiByte
(
CP_ACP
,
0
,
host
,
-
1
,
(
LPSTR
)
ptr
,
host_len
,
NULL
,
NULL
);
SysFreeString
(
host
);
ptr
+=
host_len
;
*
(
DWORD
*
)(
secid
+
len
)
=
zone
;
*
(
DWORD
*
)
ptr
=
zone
;
}
*
secid_len
=
len
+
sizeof
(
DWORD
);
return
S_OK
;
}
static
HRESULT
get_security_id_for_url
(
LPCWSTR
url
,
BYTE
*
secid
,
DWORD
*
secid_len
)
{
HRESULT
hres
;
DWORD
zone
=
URLZONE_INVALID
;
LPWSTR
secur_url
=
NULL
;
IUri
*
uri
;
hres
=
map_url_to_zone
(
url
,
&
zone
,
&
secur_url
);
if
(
FAILED
(
hres
))
return
hres
==
0x80041001
?
E_INVALIDARG
:
hres
;
hres
=
CreateUri
(
secur_url
,
0
,
0
,
&
uri
);
CoTaskMemFree
(
secur_url
);
if
(
FAILED
(
hres
))
return
hres
;
hres
=
generate_security_id
(
uri
,
secid
,
secid_len
,
zone
);
IUri_Release
(
uri
);
return
hres
;
}
static
HRESULT
get_security_id_for_uri
(
IUri
*
uri
,
BYTE
*
secid
,
DWORD
*
secid_len
)
{
HRESULT
hres
;
IUri
*
secur_uri
;
DWORD
zone
=
URLZONE_INVALID
;
hres
=
map_uri_to_zone
(
uri
,
&
zone
,
&
secur_uri
);
if
(
FAILED
(
hres
))
return
hres
;
hres
=
generate_security_id
(
secur_uri
,
secid
,
secid_len
,
zone
);
IUri_Release
(
secur_uri
);
return
hres
;
}
/***********************************************************************
* InternetSecurityManager implementation
*
...
...
@@ -955,7 +1016,7 @@ static HRESULT WINAPI SecManagerImpl_GetSecurityId(IInternetSecurityManagerEx2 *
if
(
dwReserved
)
FIXME
(
"dwReserved is not supported
\n
"
);
return
get_security_id
(
pwszUrl
,
pbSecurityId
,
pcbSecurityId
);
return
get_security_id
_for_url
(
pwszUrl
,
pbSecurityId
,
pcbSecurityId
);
}
...
...
@@ -1127,7 +1188,7 @@ static HRESULT WINAPI SecManagerImpl_MapUrlToZoneEx2(IInternetSecurityManagerEx2
if
(
dwFlags
)
FIXME
(
"Unsupported flags: %08x
\n
"
,
dwFlags
);
return
map_uri_to_zone
(
pUri
,
pdwZone
);
return
map_uri_to_zone
(
pUri
,
pdwZone
,
NULL
);
}
static
HRESULT
WINAPI
SecManagerImpl_ProcessUrlActionEx2
(
IInternetSecurityManagerEx2
*
iface
,
...
...
@@ -1144,8 +1205,15 @@ static HRESULT WINAPI SecManagerImpl_GetSecurityIdEx2(IInternetSecurityManagerEx
IUri
*
pUri
,
BYTE
*
pbSecurityId
,
DWORD
*
pcbSecurityId
,
DWORD_PTR
dwReserved
)
{
SecManagerImpl
*
This
=
impl_from_IInternetSecurityManagerEx2
(
iface
);
FIXME
(
"(%p)->(%p %p %p %08x) stub
\n
"
,
This
,
pUri
,
pbSecurityId
,
pcbSecurityId
,
(
DWORD
)
dwReserved
);
return
E_NOTIMPL
;
TRACE
(
"(%p)->(%p %p %p %08x) stub
\n
"
,
This
,
pUri
,
pbSecurityId
,
pcbSecurityId
,
(
DWORD
)
dwReserved
);
if
(
dwReserved
)
FIXME
(
"dwReserved is not supported yet
\n
"
);
if
(
!
pUri
||
!
pcbSecurityId
||
!
pbSecurityId
)
return
E_INVALIDARG
;
return
get_security_id_for_uri
(
pUri
,
pbSecurityId
,
pcbSecurityId
);
}
static
HRESULT
WINAPI
SecManagerImpl_QueryCustomPolicyEx2
(
IInternetSecurityManagerEx2
*
iface
,
...
...
dlls/urlmon/tests/sec_mgr.c
View file @
269fe5a4
...
...
@@ -442,8 +442,8 @@ static void test_SecurityManager(void)
memset
(
buf
,
0xf0
,
sizeof
(
buf
));
hres
=
IInternetSecurityManager_GetSecurityId
(
secmgr
,
url14
,
buf
,
&
size
,
0
);
ok
(
hres
==
S_OK
,
"GetSecurityId failed: %08x, expected S_OK
\n
"
,
hres
);
todo_wine
ok
(
size
==
sizeof
(
secid14
),
"size=%d
\n
"
,
size
);
todo_wine
ok
(
!
memcmp
(
buf
,
secid14
,
size
),
"wrong secid
\n
"
);
ok
(
size
==
sizeof
(
secid14
),
"size=%d
\n
"
,
size
);
ok
(
!
memcmp
(
buf
,
secid14
,
size
),
"wrong secid
\n
"
);
zone
=
100
;
hres
=
IInternetSecurityManager_MapUrlToZone
(
secmgr
,
NULL
,
&
zone
,
0
);
...
...
@@ -1751,6 +1751,7 @@ static void test_InternetGetSecurityUrlEx_Pluggable(void)
static
const
BYTE
secidex2_1
[]
=
{
'z'
,
'i'
,
'p'
,
':'
,
'/'
,
'/'
,
't'
,
'e'
,
's'
,
't'
,
'i'
,
'n'
,
'g'
,
'.'
,
'c'
,
'o'
,
'm'
,
'/'
,
3
,
0
,
0
,
0
};
static
const
BYTE
secidex2_2
[]
=
{
'z'
,
'i'
,
'p'
,
':'
,
't'
,
'e'
,
's'
,
't'
,
'i'
,
'n'
,
'g'
,
'.'
,
'c'
,
'o'
,
'm'
,
3
,
0
,
0
,
0
};
static
const
BYTE
secidex2_3
[]
=
{
'*'
,
':'
,
't'
,
'e'
,
's'
,
't'
,
'i'
,
'n'
,
'g'
,
'.'
,
'c'
,
'o'
,
'm'
,
3
,
0
,
0
,
0
};
static
const
struct
{
const
char
*
uri
;
...
...
@@ -1763,17 +1764,19 @@ static const struct {
HRESULT
secid_hres
;
BOOL
secid_todo
;
}
sec_mgr_ex2_tests
[]
=
{
{
"res://mshtml.dll/blank.htm"
,
0
,
S_OK
,
URLZONE_LOCAL_MACHINE
,
FALSE
,
secid1
,
sizeof
(
secid1
),
S_OK
,
TRUE
},
{
"index.htm"
,
Uri_CREATE_ALLOW_RELATIVE
,
0
,
URLZONE_INTERNET
,
FALSE
,
secid2
,
sizeof
(
secid2
),
S_OK
,
TRUE
},
{
"file://c:
\\
Index.html"
,
0
,
0
,
URLZONE_LOCAL_MACHINE
,
FALSE
,
secid1
,
sizeof
(
secid1
),
S_OK
,
TRUE
},
{
"http://www.zone3.winetest/"
,
0
,
0
,
URLZONE_INTERNET
,
FALSE
,
secid5
,
sizeof
(
secid5
),
S_OK
,
TRUE
},
{
"about:blank"
,
0
,
0
,
URLZONE_INTERNET
,
FALSE
,
secid6
,
sizeof
(
secid6
),
S_OK
,
TRUE
},
{
"ftp://zone3.winetest/file.test"
,
0
,
0
,
URLZONE_INTERNET
,
FALSE
,
secid7
,
sizeof
(
secid7
),
S_OK
,
TRUE
},
{
"/file/testing/test.test"
,
Uri_CREATE_ALLOW_RELATIVE
,
0
,
URLZONE_INTERNET
,
FALSE
,
NULL
,
0
,
E_INVALIDARG
,
TRUE
},
{
"zip://testing.com/"
,
0
,
0
,
URLZONE_INTERNET
,
FALSE
,
secidex2_1
,
sizeof
(
secidex2_1
),
S_OK
,
TRUE
},
{
"zip:testing.com"
,
0
,
0
,
URLZONE_INTERNET
,
FALSE
,
secidex2_2
,
sizeof
(
secidex2_2
),
S_OK
,
TRUE
},
{
"http:google.com"
,
0
,
S_OK
,
URLZONE_INVALID
,
FALSE
,
NULL
,
0
,
E_INVALIDARG
,
TRUE
},
{
"http:/google.com"
,
0
,
S_OK
,
URLZONE_INVALID
,
FALSE
,
NULL
,
0
,
E_INVALIDARG
,
TRUE
}
{
"res://mshtml.dll/blank.htm"
,
0
,
S_OK
,
URLZONE_LOCAL_MACHINE
,
FALSE
,
secid1
,
sizeof
(
secid1
),
S_OK
},
{
"index.htm"
,
Uri_CREATE_ALLOW_RELATIVE
,
0
,
URLZONE_INTERNET
,
FALSE
,
secid2
,
sizeof
(
secid2
),
S_OK
},
{
"file://c:
\\
Index.html"
,
0
,
0
,
URLZONE_LOCAL_MACHINE
,
FALSE
,
secid1
,
sizeof
(
secid1
),
S_OK
},
{
"http://www.zone3.winetest/"
,
0
,
0
,
URLZONE_INTERNET
,
FALSE
,
secid5
,
sizeof
(
secid5
),
S_OK
},
{
"about:blank"
,
0
,
0
,
URLZONE_INTERNET
,
FALSE
,
secid6
,
sizeof
(
secid6
),
S_OK
},
{
"ftp://zone3.winetest/file.test"
,
0
,
0
,
URLZONE_INTERNET
,
FALSE
,
secid7
,
sizeof
(
secid7
),
S_OK
},
{
"/file/testing/test.test"
,
Uri_CREATE_ALLOW_RELATIVE
,
0
,
URLZONE_INTERNET
,
FALSE
,
NULL
,
0
,
E_INVALIDARG
},
{
"zip://testing.com/"
,
0
,
0
,
URLZONE_INTERNET
,
FALSE
,
secidex2_1
,
sizeof
(
secidex2_1
),
S_OK
},
{
"zip:testing.com"
,
0
,
0
,
URLZONE_INTERNET
,
FALSE
,
secidex2_2
,
sizeof
(
secidex2_2
),
S_OK
},
{
"http:google.com"
,
0
,
S_OK
,
URLZONE_INVALID
,
FALSE
,
NULL
,
0
,
E_INVALIDARG
},
{
"http:/google.com"
,
0
,
S_OK
,
URLZONE_INVALID
,
FALSE
,
NULL
,
0
,
E_INVALIDARG
},
{
"*:/testing"
,
0
,
S_OK
,
URLZONE_INTERNET
,
FALSE
,
NULL
,
0
,
E_INVALIDARG
},
{
"*://testing.com"
,
0
,
S_OK
,
URLZONE_INTERNET
,
FALSE
,
secidex2_3
,
sizeof
(
secidex2_3
),
S_OK
}
};
static
void
test_SecurityManagerEx2
(
void
)
...
...
@@ -1808,7 +1811,7 @@ static void test_SecurityManagerEx2(void)
ok
(
zone
==
URLZONE_INVALID
,
"zone was %d
\n
"
,
zone
);
hres
=
IInternetSecurityManagerEx2_GetSecurityIdEx2
(
sec_mgr2
,
NULL
,
buf
,
&
buf_size
,
0
);
todo_wine
ok
(
hres
==
E_INVALIDARG
,
"GetSecurityIdEx2 returned %08x, expected E_INVALIDARG
\n
"
,
hres
);
ok
(
hres
==
E_INVALIDARG
,
"GetSecurityIdEx2 returned %08x, expected E_INVALIDARG
\n
"
,
hres
);
ok
(
buf_size
==
sizeof
(
buf
),
"buf_size was %d
\n
"
,
buf_size
);
hres
=
pCreateUri
(
url5
,
0
,
0
,
&
uri
);
...
...
@@ -1819,11 +1822,11 @@ static void test_SecurityManagerEx2(void)
buf_size
=
sizeof
(
buf
);
hres
=
IInternetSecurityManagerEx2_GetSecurityIdEx2
(
sec_mgr2
,
uri
,
NULL
,
&
buf_size
,
0
);
todo_wine
ok
(
hres
==
E_INVALIDARG
||
broken
(
hres
==
S_OK
),
"GetSecurityIdEx2 failed: %08x
\n
"
,
hres
);
ok
(
hres
==
E_INVALIDARG
||
broken
(
hres
==
S_OK
),
"GetSecurityIdEx2 failed: %08x
\n
"
,
hres
);
ok
(
buf_size
==
sizeof
(
buf
),
"bug_size was %d
\n
"
,
buf_size
);
hres
=
IInternetSecurityManagerEx2_GetSecurityIdEx2
(
sec_mgr2
,
uri
,
buf
,
NULL
,
0
);
todo_wine
ok
(
hres
==
E_INVALIDARG
,
"GetSecurityIdEx2 returned %08x, expected E_INVALIDARG
\n
"
,
hres
);
ok
(
hres
==
E_INVALIDARG
,
"GetSecurityIdEx2 returned %08x, expected E_INVALIDARG
\n
"
,
hres
);
IUri_Release
(
uri
);
...
...
@@ -1889,7 +1892,7 @@ static void test_SecurityManagerEx2(void)
memset
(
buf
,
0xf0
,
buf_size
);
hres
=
IInternetSecurityManagerEx2_GetSecurityIdEx2
(
sec_mgr2
,
uri
,
buf
,
&
buf_size
,
(
DWORD_PTR
)
domainW
);
todo_wine
ok
(
hres
==
S_OK
,
"GetSecurityIdEx2 failed: %08x
\n
"
,
hres
);
ok
(
hres
==
S_OK
,
"GetSecurityIdEx2 failed: %08x
\n
"
,
hres
);
todo_wine
ok
(
buf_size
==
sizeof
(
secid13
),
"buf_size was %d
\n
"
,
buf_size
);
todo_wine
ok
(
!
memcmp
(
buf
,
secid13
,
sizeof
(
secid13
)),
"Got wrong secid
\n
"
);
...
...
@@ -1897,9 +1900,9 @@ static void test_SecurityManagerEx2(void)
memset
(
buf
,
0xf0
,
buf_size
);
hres
=
IInternetSecurityManagerEx2_GetSecurityIdEx2
(
sec_mgr2
,
uri
,
buf
,
&
buf_size
,
0
);
todo_wine
ok
(
hres
==
S_OK
,
"GetSecurityIdEx2 failed: %08x
\n
"
,
hres
);
todo_wine
ok
(
buf_size
==
sizeof
(
secid13_2
),
"buf_size was %d
\n
"
,
buf_size
);
todo_wine
ok
(
!
memcmp
(
buf
,
secid13_2
,
sizeof
(
secid13_2
)),
"Got wrong secid
\n
"
);
ok
(
hres
==
S_OK
,
"GetSecurityIdEx2 failed: %08x
\n
"
,
hres
);
ok
(
buf_size
==
sizeof
(
secid13_2
),
"buf_size was %d
\n
"
,
buf_size
);
ok
(
!
memcmp
(
buf
,
secid13_2
,
sizeof
(
secid13_2
)),
"Got wrong secid
\n
"
);
IUri_Release
(
uri
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment