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
ad912961
Commit
ad912961
authored
Oct 08, 2013
by
Jacek Caban
Committed by
Alexandre Julliard
Oct 08, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt32: Allocate BASE_CONTEXT in the beginning of the memory block.
parent
12982d86
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
60 deletions
+48
-60
context.c
dlls/crypt32/context.c
+46
-59
store.c
dlls/crypt32/store.c
+2
-1
No files found.
dlls/crypt32/context.c
View file @
ad912961
...
...
@@ -41,123 +41,110 @@ typedef struct _BASE_CONTEXT
}
u
;
}
BASE_CONTEXT
;
#define CONTEXT_FROM_BASE_CONTEXT(p
, s) ((LPBYTE)(p) - (s)
)
#define BASE_CONTEXT_FROM_CONTEXT(p
, s) (BASE_CONTEXT*)((LPBYTE)(p) + (s)
)
#define CONTEXT_FROM_BASE_CONTEXT(p
) (LPBYTE)(p+1
)
#define BASE_CONTEXT_FROM_CONTEXT(p
) ((BASE_CONTEXT*)(p)-1
)
void
*
Context_CreateDataContext
(
size_t
contextSize
)
{
void
*
ret
=
CryptMemAlloc
(
contextSize
+
sizeof
(
BASE_CONTEXT
))
;
BASE_CONTEXT
*
context
;
if
(
ret
)
{
BASE_CONTEXT
*
context
=
(
BASE_CONTEXT
*
)((
LPBYTE
)
ret
+
contextSize
)
;
context
=
CryptMemAlloc
(
contextSize
+
sizeof
(
BASE_CONTEXT
));
if
(
!
context
)
return
NULL
;
context
->
ref
=
1
;
context
->
type
=
ContextTypeData
;
context
->
u
.
properties
=
ContextPropertyList_Create
();
if
(
!
context
->
u
.
properties
)
{
CryptMemFree
(
ret
);
ret
=
NULL
;
}
context
->
ref
=
1
;
context
->
type
=
ContextTypeData
;
context
->
u
.
properties
=
ContextPropertyList_Create
();
if
(
!
context
->
u
.
properties
)
{
CryptMemFree
(
context
);
return
NULL
;
}
TRACE
(
"returning %p
\n
"
,
ret
);
return
ret
;
TRACE
(
"returning %p
\n
"
,
context
);
return
CONTEXT_FROM_BASE_CONTEXT
(
context
);
}
void
*
Context_CreateLinkContext
(
unsigned
int
contextSize
,
void
*
linked
,
unsigned
int
extra
,
BOOL
addRef
)
{
void
*
context
=
CryptMemAlloc
(
contextSize
+
sizeof
(
BASE_CONTEXT
)
+
extra
)
;
BASE_CONTEXT
*
context
;
TRACE
(
"(%d, %p, %d)
\n
"
,
contextSize
,
linked
,
extra
);
if
(
context
)
{
BASE_CONTEXT
*
linkContext
=
(
BASE_CONTEXT
*
)
BASE_CONTEXT_FROM_CONTEXT
(
context
,
contextSize
);
BASE_CONTEXT
*
linkedBase
=
BASE_CONTEXT_FROM_CONTEXT
(
linked
,
contextSize
);
memcpy
(
context
,
linked
,
contextSize
);
linkContext
->
ref
=
1
;
linkContext
->
type
=
ContextTypeLink
;
linkContext
->
u
.
linked
=
linkedBase
;
if
(
addRef
)
Context_AddRef
(
linked
,
contextSize
);
TRACE
(
"%p's ref count is %d
\n
"
,
context
,
linkContext
->
ref
);
}
context
=
CryptMemAlloc
(
contextSize
+
sizeof
(
BASE_CONTEXT
)
+
extra
);
if
(
!
context
)
return
NULL
;
memcpy
(
CONTEXT_FROM_BASE_CONTEXT
(
context
),
linked
,
contextSize
);
context
->
ref
=
1
;
context
->
type
=
ContextTypeLink
;
context
->
u
.
linked
=
BASE_CONTEXT_FROM_CONTEXT
(
linked
);
if
(
addRef
)
Context_AddRef
(
linked
,
contextSize
);
TRACE
(
"returning %p
\n
"
,
context
);
return
context
;
return
CONTEXT_FROM_BASE_CONTEXT
(
context
)
;
}
void
Context_AddRef
(
void
*
context
,
size_t
contextSize
)
{
BASE_CONTEXT
*
baseContext
=
BASE_CONTEXT_FROM_CONTEXT
(
context
,
contextSize
);
BASE_CONTEXT
*
baseContext
=
BASE_CONTEXT_FROM_CONTEXT
(
context
);
InterlockedIncrement
(
&
baseContext
->
ref
);
TRACE
(
"%p's ref count is %d
\n
"
,
context
,
baseContext
->
ref
);
if
(
baseContext
->
type
==
ContextTypeLink
)
{
void
*
linkedContext
=
Context_GetLinkedContext
(
context
,
contextSize
);
BASE_CONTEXT
*
linkedBase
=
BASE_CONTEXT_FROM_CONTEXT
(
linkedContext
,
contextSize
);
BASE_CONTEXT
*
linkedBase
=
baseContext
->
u
.
linked
;
/* Add-ref the linked contexts too */
while
(
linked
Context
&&
linkedBase
->
type
==
ContextTypeLink
)
while
(
linked
Base
&&
linkedBase
->
type
==
ContextTypeLink
)
{
InterlockedIncrement
(
&
linkedBase
->
ref
);
TRACE
(
"%p's ref count is %d
\n
"
,
linkedContext
,
linkedBase
->
ref
);
linkedContext
=
Context_GetLinkedContext
(
linkedContext
,
contextSize
);
if
(
linkedContext
)
linkedBase
=
BASE_CONTEXT_FROM_CONTEXT
(
linkedContext
,
contextSize
);
else
linkedBase
=
NULL
;
TRACE
(
"%p's ref count is %d
\n
"
,
linkedBase
,
linkedBase
->
ref
);
linkedBase
=
linkedBase
->
u
.
linked
;
}
if
(
linked
Context
)
if
(
linked
Base
)
{
/* It's not a link context, so it wasn't add-ref'ed in the while
* loop, so add-ref it here.
*/
linkedBase
=
BASE_CONTEXT_FROM_CONTEXT
(
linkedContext
,
contextSize
);
InterlockedIncrement
(
&
linkedBase
->
ref
);
TRACE
(
"%p's ref count is %d
\n
"
,
linked
Context
,
linkedBase
->
ref
);
TRACE
(
"%p's ref count is %d
\n
"
,
linked
Base
,
linkedBase
->
ref
);
}
}
}
void
*
Context_GetExtra
(
const
void
*
context
,
size_t
contextSize
)
{
BASE_CONTEXT
*
baseContext
=
BASE_CONTEXT_FROM_CONTEXT
(
context
,
contextSize
);
BASE_CONTEXT
*
baseContext
=
BASE_CONTEXT_FROM_CONTEXT
(
context
);
assert
(
baseContext
->
type
==
ContextTypeLink
);
return
(
LPBYTE
)
baseContext
+
sizeof
(
BASE_CONTEXT
)
;
return
(
LPBYTE
)
CONTEXT_FROM_BASE_CONTEXT
(
baseContext
)
+
contextSize
;
}
void
*
Context_GetLinkedContext
(
void
*
context
,
size_t
contextSize
)
{
BASE_CONTEXT
*
baseContext
=
BASE_CONTEXT_FROM_CONTEXT
(
context
,
contextSize
);
BASE_CONTEXT
*
baseContext
=
BASE_CONTEXT_FROM_CONTEXT
(
context
);
assert
(
baseContext
->
type
==
ContextTypeLink
);
return
CONTEXT_FROM_BASE_CONTEXT
(
baseContext
->
u
.
linked
,
contextSize
);
return
CONTEXT_FROM_BASE_CONTEXT
(
baseContext
->
u
.
linked
);
}
CONTEXT_PROPERTY_LIST
*
Context_GetProperties
(
const
void
*
context
,
size_t
contextSize
)
{
BASE_CONTEXT
*
ptr
=
BASE_CONTEXT_FROM_CONTEXT
(
context
,
contextSize
);
BASE_CONTEXT
*
ptr
=
BASE_CONTEXT_FROM_CONTEXT
(
context
);
while
(
ptr
&&
ptr
->
type
==
ContextTypeLink
)
ptr
=
ptr
->
u
.
linked
;
return
(
ptr
&&
ptr
->
type
==
ContextTypeData
)
?
ptr
->
u
.
properties
:
NULL
;
}
BOOL
Context_Release
(
void
*
context
,
size_t
contextSize
,
ContextFreeFunc
dataContextFree
)
{
BASE_CONTEXT
*
base
=
BASE_CONTEXT_FROM_CONTEXT
(
context
,
contextSize
);
BASE_CONTEXT
*
base
=
BASE_CONTEXT_FROM_CONTEXT
(
context
);
BOOL
ret
=
TRUE
;
if
(
base
->
ref
<=
0
)
...
...
@@ -171,7 +158,7 @@ BOOL Context_Release(void *context, size_t contextSize,
* it as well, using the same offset and data free function.
*/
ret
=
Context_Release
(
CONTEXT_FROM_BASE_CONTEXT
(
base
->
u
.
linked
,
contextSize
),
contextSize
,
dataContextFree
);
base
->
u
.
linked
),
contextSize
,
dataContextFree
);
}
if
(
InterlockedDecrement
(
&
base
->
ref
)
==
0
)
{
...
...
@@ -181,7 +168,7 @@ BOOL Context_Release(void *context, size_t contextSize,
ContextPropertyList_Free
(
base
->
u
.
properties
);
dataContextFree
(
context
);
}
CryptMemFree
(
context
);
CryptMemFree
(
base
);
}
else
TRACE
(
"%p's ref count is %d
\n
"
,
context
,
base
->
ref
);
...
...
@@ -238,7 +225,7 @@ static inline struct list *ContextList_ContextToEntry(const struct ContextList *
static
inline
void
*
ContextList_EntryToContext
(
const
struct
ContextList
*
list
,
struct
list
*
entry
)
{
return
(
LPBYTE
)
entry
-
sizeof
(
BASE_CONTEXT
)
-
list
->
contextSize
;
return
(
LPBYTE
)
entry
-
list
->
contextSize
;
}
void
*
ContextList_Add
(
struct
ContextList
*
list
,
void
*
toLink
,
void
*
toReplace
)
...
...
dlls/crypt32/store.c
View file @
ad912961
...
...
@@ -160,8 +160,9 @@ static BOOL CRYPT_MemAddCert(WINECRYPT_CERTSTORE *store, void *cert,
if
(
context
)
{
context
->
hCertStore
=
store
;
if
(
ppStoreContext
)
if
(
ppStoreContext
)
{
*
ppStoreContext
=
CertDuplicateCertificateContext
(
context
);
}
}
return
context
!=
0
;
}
...
...
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