Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
098f1e6e
Commit
098f1e6e
authored
Sep 24, 2015
by
Matt Burke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use an array of forbidden custom headers
parent
d29c5412
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
9 deletions
+12
-9
src/transports/smart.c
+12
-9
No files found.
src/transports/smart.c
View file @
098f1e6e
...
...
@@ -66,14 +66,20 @@ static int git_smart__set_callbacks(
return
0
;
}
#define forbid_custom_header(disallowed_name) \
if (strncmp(disallowed_name, custom_header, name_len) == 0) \
return false
static
char
*
forbidden_custom_headers
[]
=
{
"User-Agent"
,
"Host"
,
"Accept"
,
"Content-Type"
,
"Transfer-Encoding"
,
"Content-Length"
,
};
bool
is_valid_custom_header
(
const
char
*
custom_header
)
{
const
char
*
c
;
int
name_len
;
unsigned
long
i
;
if
(
custom_header
==
NULL
)
return
true
;
...
...
@@ -95,12 +101,9 @@ bool is_valid_custom_header(const char *custom_header)
return
false
;
// Disallow headers that we set
forbid_custom_header
(
"User-Agent"
);
forbid_custom_header
(
"Host"
);
forbid_custom_header
(
"Accept"
);
forbid_custom_header
(
"Content-Type"
);
forbid_custom_header
(
"Transfer-Encoding"
);
forbid_custom_header
(
"Content-Length"
);
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
forbidden_custom_headers
);
i
++
)
if
(
strncmp
(
forbidden_custom_headers
[
i
],
custom_header
,
name_len
)
==
0
)
return
false
;
return
true
;
}
...
...
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