Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
04ffca6e
Commit
04ffca6e
authored
Jul 10, 2023
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wintrust: Use nameless unions/structs.
parent
dd44930b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
49 deletions
+47
-49
asn.c
dlls/wintrust/asn.c
+26
-26
softpub.c
dlls/wintrust/softpub.c
+0
-0
wintrust_main.c
dlls/wintrust/wintrust_main.c
+21
-23
No files found.
dlls/wintrust/asn.c
View file @
04ffca6e
...
...
@@ -21,7 +21,7 @@
#include <stdarg.h>
#include <stdio.h>
#include <assert.h>
#define NONAMELESSUNION
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
...
...
@@ -147,8 +147,8 @@ BOOL WINAPI WVTAsn1SpcLinkEncode(DWORD dwCertEncodingType,
DWORD
fileNameLen
,
fileNameLenBytes
;
LPWSTR
ptr
;
fileNameLen
=
link
->
u
.
pwszFile
?
lstrlenW
(
link
->
u
.
pwszFile
)
*
sizeof
(
WCHAR
)
:
0
;
fileNameLen
=
link
->
pwszFile
?
lstrlenW
(
link
->
pwszFile
)
*
sizeof
(
WCHAR
)
:
0
;
CRYPT_EncodeLen
(
fileNameLen
,
NULL
,
&
fileNameLenBytes
);
CRYPT_EncodeLen
(
1
+
fileNameLenBytes
+
fileNameLen
,
NULL
,
&
lenBytes
);
...
...
@@ -173,7 +173,7 @@ BOOL WINAPI WVTAsn1SpcLinkEncode(DWORD dwCertEncodingType,
*
pbEncoded
++
=
ASN_CONTEXT
;
CRYPT_EncodeLen
(
fileNameLen
,
pbEncoded
,
&
fileNameLenBytes
);
pbEncoded
+=
fileNameLenBytes
;
for
(
ptr
=
link
->
u
.
pwszFile
;
ptr
&&
*
ptr
;
ptr
++
)
for
(
ptr
=
link
->
pwszFile
;
ptr
&&
*
ptr
;
ptr
++
)
{
*
(
WCHAR
*
)
pbEncoded
=
hton16
(
*
ptr
);
pbEncoded
+=
sizeof
(
WCHAR
);
...
...
@@ -185,14 +185,14 @@ BOOL WINAPI WVTAsn1SpcLinkEncode(DWORD dwCertEncodingType,
case
SPC_MONIKER_LINK_CHOICE
:
{
DWORD
classIdLenBytes
,
dataLenBytes
,
dataLen
;
CRYPT_DATA_BLOB
classId
=
{
sizeof
(
link
->
u
.
Moniker
.
ClassId
),
(
BYTE
*
)
link
->
u
.
Moniker
.
ClassId
};
CRYPT_DATA_BLOB
classId
=
{
sizeof
(
link
->
Moniker
.
ClassId
),
(
BYTE
*
)
link
->
Moniker
.
ClassId
};
CRYPT_EncodeLen
(
classId
.
cbData
,
NULL
,
&
classIdLenBytes
);
CRYPT_EncodeLen
(
link
->
u
.
Moniker
.
SerializedData
.
cbData
,
NULL
,
CRYPT_EncodeLen
(
link
->
Moniker
.
SerializedData
.
cbData
,
NULL
,
&
dataLenBytes
);
dataLen
=
2
+
classIdLenBytes
+
classId
.
cbData
+
dataLenBytes
+
link
->
u
.
Moniker
.
SerializedData
.
cbData
;
dataLenBytes
+
link
->
Moniker
.
SerializedData
.
cbData
;
CRYPT_EncodeLen
(
dataLen
,
NULL
,
&
lenBytes
);
bytesNeeded
=
1
+
dataLen
+
lenBytes
;
if
(
!
pbEncoded
)
...
...
@@ -217,9 +217,9 @@ BOOL WINAPI WVTAsn1SpcLinkEncode(DWORD dwCertEncodingType,
CRYPT_AsnEncodeOctets
(
X509_ASN_ENCODING
,
NULL
,
&
classId
,
pbEncoded
,
&
size
);
pbEncoded
+=
size
;
size
=
1
+
dataLenBytes
+
link
->
u
.
Moniker
.
SerializedData
.
cbData
;
size
=
1
+
dataLenBytes
+
link
->
Moniker
.
SerializedData
.
cbData
;
CRYPT_AsnEncodeOctets
(
X509_ASN_ENCODING
,
NULL
,
&
link
->
u
.
Moniker
.
SerializedData
,
pbEncoded
,
&
size
);
&
link
->
Moniker
.
SerializedData
,
pbEncoded
,
&
size
);
pbEncoded
+=
size
;
ret
=
TRUE
;
}
...
...
@@ -233,7 +233,7 @@ BOOL WINAPI WVTAsn1SpcLinkEncode(DWORD dwCertEncodingType,
/* Check for invalid characters in URL */
ret
=
TRUE
;
urlLen
=
0
;
for
(
ptr
=
link
->
u
.
pwszUrl
;
ptr
&&
*
ptr
&&
ret
;
ptr
++
)
for
(
ptr
=
link
->
pwszUrl
;
ptr
&&
*
ptr
&&
ret
;
ptr
++
)
if
(
*
ptr
>
0x7f
)
{
*
pcbEncoded
=
0
;
...
...
@@ -260,7 +260,7 @@ BOOL WINAPI WVTAsn1SpcLinkEncode(DWORD dwCertEncodingType,
*
pbEncoded
++
=
ASN_CONTEXT
;
CRYPT_EncodeLen
(
urlLen
,
pbEncoded
,
&
lenBytes
);
pbEncoded
+=
lenBytes
;
for
(
ptr
=
link
->
u
.
pwszUrl
;
ptr
&&
*
ptr
;
ptr
++
)
for
(
ptr
=
link
->
pwszUrl
;
ptr
&&
*
ptr
;
ptr
++
)
*
pbEncoded
++
=
(
BYTE
)
*
ptr
;
}
}
...
...
@@ -1256,10 +1256,10 @@ static BOOL CRYPT_AsnDecodeSPCLinkInternal(DWORD dwCertEncodingType,
link
->
dwLinkChoice
=
SPC_URL_LINK_CHOICE
;
for
(
i
=
0
;
i
<
dataLen
;
i
++
)
link
->
u
.
pwszUrl
[
i
]
=
link
->
pwszUrl
[
i
]
=
*
(
pbEncoded
+
1
+
lenBytes
+
i
);
link
->
u
.
pwszUrl
[
i
]
=
'\0'
;
TRACE
(
"returning url %s
\n
"
,
debugstr_w
(
link
->
u
.
pwszUrl
));
link
->
pwszUrl
[
i
]
=
'\0'
;
TRACE
(
"returning url %s
\n
"
,
debugstr_w
(
link
->
pwszUrl
));
}
break
;
case
ASN_CONSTRUCTOR
|
ASN_CONTEXT
|
1
:
...
...
@@ -1306,13 +1306,13 @@ static BOOL CRYPT_AsnDecodeSPCLinkInternal(DWORD dwCertEncodingType,
/* pwszFile pointer was set by caller, copy it
* before overwriting it
*/
link
->
u
.
Moniker
.
SerializedData
.
pbData
=
(
BYTE
*
)
link
->
u
.
pwszFile
;
memcpy
(
link
->
u
.
Moniker
.
ClassId
,
classId
.
pbData
,
link
->
Moniker
.
SerializedData
.
pbData
=
(
BYTE
*
)
link
->
pwszFile
;
memcpy
(
link
->
Moniker
.
ClassId
,
classId
.
pbData
,
classId
.
cbData
);
memcpy
(
link
->
u
.
Moniker
.
SerializedData
.
pbData
,
memcpy
(
link
->
Moniker
.
SerializedData
.
pbData
,
data
.
pbData
,
data
.
cbData
);
link
->
u
.
Moniker
.
SerializedData
.
cbData
=
data
.
cbData
;
link
->
Moniker
.
SerializedData
.
cbData
=
data
.
cbData
;
}
}
}
...
...
@@ -1344,10 +1344,10 @@ static BOOL CRYPT_AsnDecodeSPCLinkInternal(DWORD dwCertEncodingType,
link
->
dwLinkChoice
=
SPC_FILE_LINK_CHOICE
;
for
(
i
=
0
;
i
<
dataLen
/
sizeof
(
WCHAR
);
i
++
)
link
->
u
.
pwszFile
[
i
]
=
link
->
pwszFile
[
i
]
=
hton16
(
*
(
const
WORD
*
)(
ptr
+
i
*
sizeof
(
WCHAR
)));
link
->
u
.
pwszFile
[
realDataLen
/
sizeof
(
WCHAR
)]
=
'\0'
;
TRACE
(
"returning file %s
\n
"
,
debugstr_w
(
link
->
u
.
pwszFile
));
link
->
pwszFile
[
realDataLen
/
sizeof
(
WCHAR
)]
=
'\0'
;
TRACE
(
"returning file %s
\n
"
,
debugstr_w
(
link
->
pwszFile
));
}
}
else
...
...
@@ -1366,7 +1366,7 @@ static BOOL CRYPT_AsnDecodeSPCLinkInternal(DWORD dwCertEncodingType,
PSPC_LINK
link
=
pvStructInfo
;
link
->
dwLinkChoice
=
SPC_FILE_LINK_CHOICE
;
link
->
u
.
pwszFile
[
0
]
=
'\0'
;
link
->
pwszFile
[
0
]
=
'\0'
;
ret
=
TRUE
;
}
}
...
...
@@ -1408,7 +1408,7 @@ BOOL WINAPI WVTAsn1SpcLinkDecode(DWORD dwCertEncodingType,
{
SPC_LINK
*
link
=
pvStructInfo
;
link
->
u
.
pwszFile
=
link
->
pwszFile
=
(
LPWSTR
)((
BYTE
*
)
pvStructInfo
+
sizeof
(
SPC_LINK
));
ret
=
CRYPT_AsnDecodeSPCLinkInternal
(
dwCertEncodingType
,
lpszStructType
,
pbEncoded
,
cbEncoded
,
dwFlags
,
pvStructInfo
,
...
...
@@ -1773,7 +1773,7 @@ static BOOL WINAPI CRYPT_AsnDecodeSPCLinkPointer(DWORD dwCertEncodingType,
/* Set imageData's pointer if necessary */
if
(
size
>
sizeof
(
SPC_LINK
))
{
(
*
pLink
)
->
u
.
pwszUrl
=
(
*
pLink
)
->
pwszUrl
=
(
LPWSTR
)((
BYTE
*
)
*
pLink
+
sizeof
(
SPC_LINK
));
}
ret
=
CRYPT_AsnDecodeSPCLinkInternal
(
dwCertEncodingType
,
...
...
dlls/wintrust/softpub.c
View file @
04ffca6e
This diff is collapsed.
Click to expand it.
dlls/wintrust/wintrust_main.c
View file @
04ffca6e
...
...
@@ -19,8 +19,6 @@
#include <stdarg.h>
#define NONAMELESSUNION
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
...
...
@@ -92,7 +90,7 @@ BOOL WINAPI TrustIsCertificateSelfSigned( PCCERT_CONTEXT cert )
if
(
directoryName
)
{
ret
=
CertCompareCertificateName
(
cert
->
dwCertEncodingType
,
&
directoryName
->
u
.
DirectoryName
,
&
cert
->
pCertInfo
->
Issuer
)
&
directoryName
->
DirectoryName
,
&
cert
->
pCertInfo
->
Issuer
)
&&
CertCompareIntegerBlob
(
&
info
->
AuthorityCertSerialNumber
,
&
cert
->
pCertInfo
->
SerialNumber
);
}
...
...
@@ -213,10 +211,10 @@ static CRYPT_PROVIDER_DATA *WINTRUST_AllocateProviderData(void)
goto
oom
;
provData
->
cdwTrustStepErrors
=
TRUSTERROR_MAX_STEPS
;
provData
->
u
.
pPDSip
=
WINTRUST_Alloc
(
sizeof
(
PROVDATA_SIP
));
if
(
!
provData
->
u
.
pPDSip
)
provData
->
pPDSip
=
WINTRUST_Alloc
(
sizeof
(
PROVDATA_SIP
));
if
(
!
provData
->
pPDSip
)
goto
oom
;
provData
->
u
.
pPDSip
->
cbStruct
=
sizeof
(
PROVDATA_SIP
);
provData
->
pPDSip
->
cbStruct
=
sizeof
(
PROVDATA_SIP
);
provData
->
psPfns
=
WINTRUST_Alloc
(
sizeof
(
CRYPT_PROVIDER_FUNCTIONS
));
if
(
!
provData
->
psPfns
)
...
...
@@ -228,7 +226,7 @@ oom:
if
(
provData
)
{
WINTRUST_Free
(
provData
->
padwTrustStepErrors
);
WINTRUST_Free
(
provData
->
u
.
pPDSip
);
WINTRUST_Free
(
provData
->
pPDSip
);
WINTRUST_Free
(
provData
->
psPfns
);
WINTRUST_Free
(
provData
);
}
...
...
@@ -312,7 +310,7 @@ static LONG WINTRUST_DefaultVerify(HWND hwnd, GUID *actionID,
error:
WINTRUST_Free
(
provData
->
padwTrustStepErrors
);
WINTRUST_Free
(
provData
->
u
.
pPDSip
);
WINTRUST_Free
(
provData
->
pPDSip
);
WINTRUST_Free
(
provData
->
psPfns
);
WINTRUST_Free
(
provData
);
...
...
@@ -335,7 +333,7 @@ static LONG WINTRUST_DefaultClose(HWND hwnd, GUID *actionID,
err
=
provData
->
psPfns
->
pfnCleanupPolicy
(
provData
);
WINTRUST_Free
(
provData
->
padwTrustStepErrors
);
WINTRUST_Free
(
provData
->
u
.
pPDSip
);
WINTRUST_Free
(
provData
->
pPDSip
);
WINTRUST_Free
(
provData
->
psPfns
);
WINTRUST_Free
(
provData
);
data
->
hWVTStateData
=
NULL
;
...
...
@@ -371,7 +369,7 @@ static LONG WINTRUST_PublishedSoftware(HWND hwnd, GUID *actionID,
TRACE
(
"subjectFile->lpPath: %s
\n
"
,
debugstr_w
(
subjectFile
->
lpPath
));
fileInfo
.
pcwszFilePath
=
subjectFile
->
lpPath
;
fileInfo
.
hFile
=
subjectFile
->
hFile
;
wintrust_data
.
u
.
pFile
=
&
fileInfo
;
wintrust_data
.
pFile
=
&
fileInfo
;
wintrust_data
.
dwUnionChoice
=
WTD_CHOICE_FILE
;
wintrust_data
.
dwUIChoice
=
WTD_UI_NONE
;
...
...
@@ -395,16 +393,16 @@ static HRESULT WINAPI WINTRUST_CertVerifyObjTrust(CRYPT_PROVIDER_DATA *data)
switch
(
data
->
pWintrustData
->
dwUnionChoice
)
{
case
WTD_CHOICE_BLOB
:
if
(
data
->
pWintrustData
->
u
.
pBlob
&&
if
(
data
->
pWintrustData
->
pBlob
&&
WVT_IS_CBSTRUCT_GT_MEMBEROFFSET
(
WINTRUST_BLOB_INFO
,
data
->
pWintrustData
->
u
.
pBlob
->
cbStruct
,
pbMemObject
)
&&
data
->
pWintrustData
->
u
.
pBlob
->
cbMemObject
==
data
->
pWintrustData
->
pBlob
->
cbStruct
,
pbMemObject
)
&&
data
->
pWintrustData
->
pBlob
->
cbMemObject
==
sizeof
(
CERT_VERIFY_CERTIFICATE_TRUST
)
&&
data
->
pWintrustData
->
u
.
pBlob
->
pbMemObject
)
data
->
pWintrustData
->
pBlob
->
pbMemObject
)
{
CERT_VERIFY_CERTIFICATE_TRUST
*
pCert
=
(
CERT_VERIFY_CERTIFICATE_TRUST
*
)
data
->
pWintrustData
->
u
.
pBlob
->
pbMemObject
;
data
->
pWintrustData
->
pBlob
->
pbMemObject
;
if
(
pCert
->
cbSize
==
sizeof
(
CERT_VERIFY_CERTIFICATE_TRUST
)
&&
pCert
->
pccert
)
...
...
@@ -503,7 +501,7 @@ static LONG WINTRUST_CertVerify(HWND hwnd, GUID *actionID,
error:
WINTRUST_Free
(
provData
->
padwTrustStepErrors
);
WINTRUST_Free
(
provData
->
u
.
pPDSip
);
WINTRUST_Free
(
provData
->
pPDSip
);
WINTRUST_Free
(
provData
->
psPfns
);
WINTRUST_Free
(
provData
);
...
...
@@ -641,19 +639,19 @@ static void dump_wintrust_data(WINTRUST_DATA *data)
switch
(
data
->
dwUnionChoice
)
{
case
WTD_CHOICE_FILE
:
dump_file_info
(
data
->
u
.
pFile
);
dump_file_info
(
data
->
pFile
);
break
;
case
WTD_CHOICE_CATALOG
:
dump_catalog_info
(
data
->
u
.
pCatalog
);
dump_catalog_info
(
data
->
pCatalog
);
break
;
case
WTD_CHOICE_BLOB
:
dump_blob_info
(
data
->
u
.
pBlob
);
dump_blob_info
(
data
->
pBlob
);
break
;
case
WTD_CHOICE_SIGNER
:
dump_sgnr_info
(
data
->
u
.
pSgnr
);
dump_sgnr_info
(
data
->
pSgnr
);
break
;
case
WTD_CHOICE_CERT
:
dump_cert_info
(
data
->
u
.
pCert
);
dump_cert_info
(
data
->
pCert
);
break
;
}
TRACE
(
"dwStateAction: %ld
\n
"
,
data
->
dwStateAction
);
...
...
@@ -828,7 +826,7 @@ LPCWSTR WINAPI WTHelperGetFileName(WINTRUST_DATA *data)
{
TRACE
(
"%p
\n
"
,
data
);
if
(
data
->
dwUnionChoice
==
WTD_CHOICE_FILE
)
return
data
->
u
.
pFile
->
pcwszFilePath
;
return
data
->
pFile
->
pcwszFilePath
;
else
return
NULL
;
}
...
...
@@ -840,7 +838,7 @@ HANDLE WINAPI WTHelperGetFileHandle(WINTRUST_DATA *data)
{
TRACE
(
"%p
\n
"
,
data
);
if
(
data
->
dwUnionChoice
==
WTD_CHOICE_FILE
)
return
data
->
u
.
pFile
->
hFile
;
return
data
->
pFile
->
hFile
;
else
return
INVALID_HANDLE_VALUE
;
}
...
...
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