Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
mongoose
Commits
c5850e4b
Commit
c5850e4b
authored
Sep 30, 2019
by
Sergey
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev'
parents
d5beb7ba
ff4649fe
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
3 deletions
+17
-3
mongoose.c
mongoose.c
+2
-1
mg_http.c
src/mg_http.c
+2
-1
Makefile
test/Makefile
+5
-1
fuzz.c
test/fuzz.c
+8
-0
No files found.
mongoose.c
View file @
c5850e4b
...
...
@@ -6289,7 +6289,7 @@ int mg_parse_http(const char *s, int n, struct http_message *hm, int is_req) {
}
}
else
{
s
=
mg_skip
(
s
,
end
,
" "
,
&
hm
->
proto
);
if
(
end
-
s
<
4
||
s
[
3
]
!=
' '
)
return
-
1
;
if
(
end
-
s
<
4
||
s
[
0
]
<
'0'
||
s
[
0
]
>
'9'
||
s
[
3
]
!=
' '
)
return
-
1
;
hm
->
resp_code
=
atoi
(
s
);
if
(
hm
->
resp_code
<
100
||
hm
->
resp_code
>=
600
)
return
-
1
;
s
+=
4
;
...
...
@@ -6590,6 +6590,7 @@ void mg_http_handler(struct mg_connection *nc, int ev,
struct
mg_http_multipart_part
mp
;
memset
(
&
mp
,
0
,
sizeof
(
mp
));
mp
.
status
=
-
1
;
mp
.
user_data
=
pd
->
mp_stream
.
user_data
;
mp
.
var_name
=
pd
->
mp_stream
.
var_name
;
mp
.
file_name
=
pd
->
mp_stream
.
file_name
;
mg_call
(
nc
,
(
pd
->
endpoint_handler
?
pd
->
endpoint_handler
:
nc
->
handler
),
...
...
src/mg_http.c
View file @
c5850e4b
...
...
@@ -455,7 +455,7 @@ int mg_parse_http(const char *s, int n, struct http_message *hm, int is_req) {
}
}
else
{
s
=
mg_skip
(
s
,
end
,
" "
,
&
hm
->
proto
);
if
(
end
-
s
<
4
||
s
[
3
]
!=
' '
)
return
-
1
;
if
(
end
-
s
<
4
||
s
[
0
]
<
'0'
||
s
[
0
]
>
'9'
||
s
[
3
]
!=
' '
)
return
-
1
;
hm
->
resp_code
=
atoi
(
s
);
if
(
hm
->
resp_code
<
100
||
hm
->
resp_code
>=
600
)
return
-
1
;
s
+=
4
;
...
...
@@ -756,6 +756,7 @@ void mg_http_handler(struct mg_connection *nc, int ev,
struct
mg_http_multipart_part
mp
;
memset
(
&
mp
,
0
,
sizeof
(
mp
));
mp
.
status
=
-
1
;
mp
.
user_data
=
pd
->
mp_stream
.
user_data
;
mp
.
var_name
=
pd
->
mp_stream
.
var_name
;
mp
.
file_name
=
pd
->
mp_stream
.
file_name
;
mg_call
(
nc
,
(
pd
->
endpoint_handler
?
pd
->
endpoint_handler
:
nc
->
handler
),
...
...
test/Makefile
View file @
c5850e4b
...
...
@@ -17,7 +17,7 @@ else
COMMON_PARENT
=
$(SRC_DIR)
endif
TEST_SOURCES
=
unit_test.c test_util.c test_main.c
TEST_SOURCES
=
unit_test.c test_util.c test_main.c
fuzz.c
AMALGAMATED_SOURCES
=
../mongoose.c
KRYPTON_PATH
=
$(REPO_ROOT)
/krypton
...
...
@@ -118,6 +118,10 @@ clean_index_cgi:
@
echo
-e
"CLEAN
\t
index.cgi"
@
rm
-f
data/cgi/index.cgi
*
fuzz
:
$(CC)
fuzz.c ../mongoose.c
-o
/tmp/
$@
-fsanitize
=
fuzzer,address
-g
-I
..
/tmp/
$@
# Interactive:
# docker run -v $(CURDIR)/../..:/cesanta -t -i --entrypoint=/bin/bash cesanta/mongoose_test
docker
:
...
...
test/fuzz.c
0 → 100644
View file @
c5850e4b
#include "mongoose.h"
int
LLVMFuzzerTestOneInput
(
const
uint8_t
*
data
,
size_t
size
)
{
struct
http_message
req
;
mg_parse_http
((
const
char
*
)
data
,
size
,
&
req
,
0
);
mg_parse_http
((
const
char
*
)
data
,
size
,
&
req
,
1
);
return
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