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
6f2513d3
Commit
6f2513d3
authored
Oct 07, 2010
by
Andrew Nguyen
Committed by
Alexandre Julliard
Oct 08, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt32: Avoid relying on PATH_MAX in import_certs_from_dir helper.
PATH_MAX is not guaranteed to be available on all platforms, and it is inadequate as a hardcoded buffer size anyway.
parent
1a7c76c7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
10 deletions
+40
-10
rootstore.c
dlls/crypt32/rootstore.c
+40
-10
No files found.
dlls/crypt32/rootstore.c
View file @
6f2513d3
...
...
@@ -326,6 +326,32 @@ static BOOL import_certs_from_file(int fd, HCERTSTORE store)
static
BOOL
import_certs_from_path
(
LPCSTR
path
,
HCERTSTORE
store
,
BOOL
allow_dir
);
static
BOOL
check_buffer_resize
(
char
**
ptr_buf
,
size_t
*
buf_size
,
size_t
check_size
)
{
if
(
check_size
>
*
buf_size
)
{
*
buf_size
=
check_size
;
if
(
*
ptr_buf
)
{
char
*
realloc_buf
=
CryptMemRealloc
(
*
ptr_buf
,
*
buf_size
);
if
(
!
realloc_buf
)
return
FALSE
;
*
ptr_buf
=
realloc_buf
;
}
else
{
*
ptr_buf
=
CryptMemAlloc
(
*
buf_size
);
if
(
!*
ptr_buf
)
return
FALSE
;
}
}
return
TRUE
;
}
/* Opens path, which must be a directory, and imports certificates from every
* file in the directory into store.
* Returns TRUE if any certificates were successfully imported.
...
...
@@ -341,23 +367,27 @@ static BOOL import_certs_from_dir(LPCSTR path, HCERTSTORE store)
dir
=
opendir
(
path
);
if
(
dir
)
{
size_t
bufsize
=
strlen
(
path
)
+
1
+
PATH_MAX
+
1
;
char
*
filebuf
=
CryptMemAlloc
(
bufsize
)
;
size_t
path_len
=
strlen
(
path
),
bufsize
=
0
;
char
*
filebuf
=
NULL
;
if
(
filebuf
)
struct
dirent
*
entry
;
while
((
entry
=
readdir
(
dir
)))
{
struct
dirent
*
entry
;
while
((
entry
=
readdir
(
dir
)))
if
(
strcmp
(
entry
->
d_name
,
"."
)
&&
strcmp
(
entry
->
d_name
,
".."
))
{
if
(
strcmp
(
entry
->
d_name
,
"."
)
&&
strcmp
(
entry
->
d_name
,
".."
))
size_t
name_len
=
strlen
(
entry
->
d_name
);
if
(
!
check_buffer_resize
(
&
filebuf
,
&
bufsize
,
path_len
+
1
+
name_len
+
1
))
{
snprintf
(
filebuf
,
bufsize
,
"%s/%s"
,
path
,
entry
->
d_name
);
if
(
import_certs_from_path
(
filebuf
,
store
,
FALSE
)
&&
!
ret
)
ret
=
TRUE
;
ERR
(
"Path buffer (re)allocation failed with out of memory condition
\n
"
);
break
;
}
snprintf
(
filebuf
,
bufsize
,
"%s/%s"
,
path
,
entry
->
d_name
);
if
(
import_certs_from_path
(
filebuf
,
store
,
FALSE
)
&&
!
ret
)
ret
=
TRUE
;
}
CryptMemFree
(
filebuf
);
}
CryptMemFree
(
filebuf
);
closedir
(
dir
);
}
return
ret
;
...
...
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