You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2021/06/21 22:44:29 UTC
[trafficserver] branch 9.0.x updated: Ensure that the
content-length value is only digits (#7964)
This is an automated email from the ASF dual-hosted git repository.
zwoop pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new 6fb5e56 Ensure that the content-length value is only digits (#7964)
6fb5e56 is described below
commit 6fb5e56a4563bb21a63fe1c8f97a34af8ed70957
Author: Bryan Call <bc...@apache.org>
AuthorDate: Mon Jun 21 15:43:42 2021 -0700
Ensure that the content-length value is only digits (#7964)
Co-authored-by: Susan Hinrichs <sh...@verizonmedia.com>
(cherry picked from commit 668d0f8668fec1cd350b0ceba3f7f8e4020ae3ca)
---
proxy/hdrs/HTTP.cc | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/proxy/hdrs/HTTP.cc b/proxy/hdrs/HTTP.cc
index 073ded9..3fba3e9 100644
--- a/proxy/hdrs/HTTP.cc
+++ b/proxy/hdrs/HTTP.cc
@@ -1192,6 +1192,17 @@ validate_hdr_content_length(HdrHeap *heap, HTTPHdrImpl *hh)
int content_length_len = 0;
const char *content_length_val = content_length_field->value_get(&content_length_len);
+ // RFC 7230 section 3.3.2
+ // Content-Length = 1*DIGIT
+ //
+ // If the content-length value contains a non-numeric value, the header is invalid
+ for (int i = 0; i < content_length_len; i++) {
+ if (!isdigit(content_length_val[i])) {
+ Debug("http", "Content-Length value contains non-digit, returning parse error");
+ return PARSE_RESULT_ERROR;
+ }
+ }
+
while (content_length_field->has_dups()) {
int content_length_len_2 = 0;
const char *content_length_val_2 = content_length_field->m_next_dup->value_get(&content_length_len_2);