Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
9ef42621
Commit
9ef42621
authored
Dec 15, 2013
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed wrong memset() in scan_directory()
parent
f5865886
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
+7
-6
mongoose.c
mongoose.c
+7
-6
No files found.
mongoose.c
View file @
9ef42621
...
@@ -1858,9 +1858,10 @@ static int scan_directory(struct connection *conn, const char *dir,
...
@@ -1858,9 +1858,10 @@ static int scan_directory(struct connection *conn, const char *dir,
char
path
[
MAX_PATH_SIZE
];
char
path
[
MAX_PATH_SIZE
];
struct
dir_entry
*
p
;
struct
dir_entry
*
p
;
struct
dirent
*
dp
;
struct
dirent
*
dp
;
int
arr_size
=
0
,
arr_ind
=
0
;
int
arr_size
=
0
,
arr_ind
=
0
,
inc
=
100
;
DIR
*
dirp
;
DIR
*
dirp
;
*
arr
=
NULL
;
if
((
dirp
=
(
opendir
(
dir
)))
==
NULL
)
return
0
;
if
((
dirp
=
(
opendir
(
dir
)))
==
NULL
)
return
0
;
while
((
dp
=
readdir
(
dirp
))
!=
NULL
)
{
while
((
dp
=
readdir
(
dirp
))
!=
NULL
)
{
...
@@ -1873,16 +1874,16 @@ static int scan_directory(struct connection *conn, const char *dir,
...
@@ -1873,16 +1874,16 @@ static int scan_directory(struct connection *conn, const char *dir,
mg_snprintf
(
path
,
sizeof
(
path
),
"%s%c%s"
,
dir
,
'/'
,
dp
->
d_name
);
mg_snprintf
(
path
,
sizeof
(
path
),
"%s%c%s"
,
dir
,
'/'
,
dp
->
d_name
);
// Resize the array if nesessary
// Resize the array if nesessary
if
(
arr_ind
>=
arr_size
-
1
)
{
if
(
arr_ind
>=
arr_size
)
{
if
((
p
=
(
struct
dir_entry
*
)
if
((
p
=
(
struct
dir_entry
*
)
realloc
(
*
arr
,
(
100
+
arr_size
)
*
sizeof
(
**
arr
)))
!=
NULL
)
{
realloc
(
*
arr
,
(
inc
+
arr_size
)
*
sizeof
(
**
arr
)))
!=
NULL
)
{
// Memset
struct
to zero, otherwize st_mtime will have garbage which
// Memset
new chunk
to zero, otherwize st_mtime will have garbage which
// can make strftime() segfault, see
// can make strftime() segfault, see
// http://code.google.com/p/mongoose/issues/detail?id=79
// http://code.google.com/p/mongoose/issues/detail?id=79
memset
(
p
+
arr_size
,
0
,
sizeof
(
**
arr
)
*
arr_size
);
memset
(
p
+
arr_size
,
0
,
sizeof
(
**
arr
)
*
inc
);
*
arr
=
p
;
*
arr
=
p
;
arr_size
+=
100
;
arr_size
+=
inc
;
}
}
}
}
...
...
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