Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
VLC
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Fatih Uzunoğlu
VLC
Commits
837f9778
Commit
837f9778
authored
1 month ago
by
Steve Lhomme
Browse files
Options
Downloads
Patches
Plain Diff
keystore: avoid dirty function pointer casts
Especially when mixing LPCWSTR and LPWSTR*.
parent
9858ba5d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/keystore/file_crypt_win32.c
+14
-8
14 additions, 8 deletions
modules/keystore/file_crypt_win32.c
with
14 additions
and
8 deletions
modules/keystore/file_crypt_win32.c
+
14
−
8
View file @
837f9778
...
...
@@ -28,8 +28,17 @@
#include
<windows.h>
#include
<dpapi.h>
typedef
BOOL
(
WINAPI
*
ProcessFunc
)(
DATA_BLOB
*
,
LPCWSTR
,
DATA_BLOB
*
,
PVOID
,
CRYPTPROTECT_PROMPTSTRUCT
*
,
DWORD
,
DATA_BLOB
*
);
typedef
BOOL
(
*
ProcessFunc
)(
DATA_BLOB
*
,
DATA_BLOB
*
);
static
BOOL
FuncProtect
(
DATA_BLOB
*
input_blob
,
DATA_BLOB
*
output_blob
)
{
return
CryptProtectData
(
input_blob
,
NULL
,
NULL
,
NULL
,
NULL
,
CRYPTPROTECT_UI_FORBIDDEN
,
output_blob
);
}
static
BOOL
FuncUnprotect
(
DATA_BLOB
*
input_blob
,
DATA_BLOB
*
output_blob
)
{
return
CryptUnprotectData
(
input_blob
,
NULL
,
NULL
,
NULL
,
NULL
,
CRYPTPROTECT_UI_FORBIDDEN
,
output_blob
);
}
static
size_t
Process
(
const
uint8_t
*
p_src
,
size_t
i_src_len
,
uint8_t
**
pp_dst
,
ProcessFunc
pf_process
)
{
...
...
@@ -40,7 +49,7 @@ static size_t Process(const uint8_t *p_src, size_t i_src_len, uint8_t **pp_dst,
};
DATA_BLOB
output_blob
;
if
(
pf_process
(
&
input_blob
,
NULL
,
NULL
,
NULL
,
NULL
,
CRYPTPROTECT_UI_FORBIDDEN
,
&
output_blob
)
==
FALSE
)
if
(
pf_process
(
&
input_blob
,
&
output_blob
)
==
FALSE
)
return
0
;
*
pp_dst
=
malloc
(
output_blob
.
cbData
);
if
(
unlikely
(
*
pp_dst
==
NULL
)
)
...
...
@@ -58,10 +67,7 @@ static size_t Decrypt( vlc_keystore *p_keystore, void *p_ctx, const uint8_t *p_s
{
VLC_UNUSED
(
p_keystore
);
VLC_UNUSED
(
p_ctx
);
// Cast the function pointer to avoid an invalid parameter warning, regarding the "description"
// parameter. It's LPCWSTR in the case of CryptProtectData, and LPWSTR* in the case of CryptUnprotect
// Since we pass NULL anyway, we don't care
return
Process
(
p_src
,
i_src_len
,
pp_dst
,
(
ProcessFunc
)
&
CryptUnprotectData
);
return
Process
(
p_src
,
i_src_len
,
pp_dst
,
FuncUnprotect
);
}
static
size_t
Encrypt
(
vlc_keystore
*
p_keystore
,
void
*
p_ctx
,
const
uint8_t
*
p_src
,
...
...
@@ -69,7 +75,7 @@ static size_t Encrypt( vlc_keystore *p_keystore, void *p_ctx, const uint8_t *p_s
{
VLC_UNUSED
(
p_keystore
);
VLC_UNUSED
(
p_ctx
);
return
Process
(
p_src
,
i_src_len
,
pp_dst
,
Crypt
Protect
Data
);
return
Process
(
p_src
,
i_src_len
,
pp_dst
,
Func
Protect
);
}
int
CryptInit
(
vlc_keystore
*
p_keystore
,
struct
crypt
*
p_crypt
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment