diff options
author | Matt Burke <spraints@gmail.com> | 2015-09-24 09:09:48 -0400 |
---|---|---|
committer | Matt Burke <spraints@gmail.com> | 2015-09-24 09:09:48 -0400 |
commit | 098f1e6e2506b3ca6376617751f877bee6fb5d20 (patch) | |
tree | cdcbe5656da7fae56bc272b74c16ce0141b9c365 | |
parent | d29c5412aa91b279b1b2db4fe57dd6fe71272b91 (diff) | |
download | libgit2-098f1e6e2506b3ca6376617751f877bee6fb5d20.tar.gz |
Use an array of forbidden custom headers
-rw-r--r-- | src/transports/smart.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/transports/smart.c b/src/transports/smart.c index 8388d9dc5..1ff39b48e 100644 --- a/src/transports/smart.c +++ b/src/transports/smart.c @@ -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; } |