Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
486dba8d
Commit
486dba8d
authored
Dec 25, 2015
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpx: Strict validation for header fields given in configuration
parent
e677e378
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
7 deletions
+18
-7
src/shrpx_config.cc
src/shrpx_config.cc
+11
-5
src/shrpx_config_test.cc
src/shrpx_config_test.cc
+7
-2
No files found.
src/shrpx_config.cc
View file @
486dba8d
...
...
@@ -276,11 +276,9 @@ std::string read_passwd_from_file(const char *filename) {
}
std
::
pair
<
std
::
string
,
std
::
string
>
parse_header
(
const
char
*
optarg
)
{
// We skip possible ":" at the start of optarg.
const
auto
*
colon
=
strchr
(
optarg
+
1
,
':'
);
const
auto
*
colon
=
strchr
(
optarg
,
':'
);
// name = ":" is not allowed
if
(
colon
==
nullptr
||
(
optarg
[
0
]
==
':'
&&
colon
==
optarg
+
1
))
{
if
(
colon
==
nullptr
||
colon
==
optarg
)
{
return
{
""
,
""
};
}
...
...
@@ -292,6 +290,14 @@ std::pair<std::string, std::string> parse_header(const char *optarg) {
std
::
string
(
value
,
strlen
(
value
)));
util
::
inp_strlower
(
p
.
first
);
if
(
!
nghttp2_check_header_name
(
reinterpret_cast
<
const
uint8_t
*>
(
p
.
first
.
c_str
()),
p
.
first
.
size
())
||
!
nghttp2_check_header_value
(
reinterpret_cast
<
const
uint8_t
*>
(
p
.
second
.
c_str
()),
p
.
second
.
size
()))
{
return
{
""
,
""
};
}
return
p
;
}
...
...
@@ -1799,7 +1805,7 @@ int parse_config(const char *opt, const char *optarg,
case
SHRPX_OPTID_ADD_RESPONSE_HEADER
:
{
auto
p
=
parse_header
(
optarg
);
if
(
p
.
first
.
empty
())
{
LOG
(
ERROR
)
<<
opt
<<
":
header field name is empty
: "
<<
optarg
;
LOG
(
ERROR
)
<<
opt
<<
":
invalid header field
: "
<<
optarg
;
return
-
1
;
}
if
(
optid
==
SHRPX_OPTID_ADD_REQUEST_HEADER
)
{
...
...
src/shrpx_config_test.cc
View file @
486dba8d
...
...
@@ -46,8 +46,7 @@ void test_shrpx_config_parse_header(void) {
CU_ASSERT
(
"b"
==
p
.
second
);
p
=
parse_header
(
":a: b"
);
CU_ASSERT
(
":a"
==
p
.
first
);
CU_ASSERT
(
"b"
==
p
.
second
);
CU_ASSERT
(
p
.
first
.
empty
());
p
=
parse_header
(
"a: :b"
);
CU_ASSERT
(
"a"
==
p
.
first
);
...
...
@@ -59,6 +58,12 @@ void test_shrpx_config_parse_header(void) {
p
=
parse_header
(
"alpha: bravo charlie"
);
CU_ASSERT
(
"alpha"
==
p
.
first
);
CU_ASSERT
(
"bravo charlie"
==
p
.
second
);
p
=
parse_header
(
"a,: b"
);
CU_ASSERT
(
p
.
first
.
empty
());
p
=
parse_header
(
"a: b
\x0a
"
);
CU_ASSERT
(
p
.
first
.
empty
());
}
void
test_shrpx_config_parse_log_format
(
void
)
{
...
...
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