8cf8f7aca3
Using the 1.4.55-1~bpo10+1 not the default version 1.4.59-1 of bullseye in order to port the patch check-content-length.patch due to the big gap of codes. Ingore the patch lighttpd-tpm-support.patch since the TPM is deprecated. Porting the spec patch spec-include-TiS-changes.patch from CentOS and disable 3 sub-packages since some configure options are disabled by spec-include-TiS-changes.patch. Story: 2009221 Task: 43608 Signed-off-by: Yue Tao <yue.tao@windriver.com> Change-Id: Iae9aa9276999a5bfa34d1980821c0d88dd3b75c6
81 lines
2.0 KiB
Diff
81 lines
2.0 KiB
Diff
From 65107586a55c594c44b0a97a2d6756f6a0f0a5ca Mon Sep 17 00:00:00 2001
|
|
From: Giao Le <giao.le@windriver.com>
|
|
Date: Mon, 27 Aug 2018 19:41:36 +0800
|
|
Subject: [PATCH] check-length
|
|
|
|
Signed-off-by: zhipengl <zhipengs.liu@intel.com>
|
|
---
|
|
src/request.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
|
|
1 file changed, 45 insertions(+)
|
|
|
|
diff --git a/src/request.c b/src/request.c
|
|
index d25e1e7..fe541a5 100644
|
|
--- a/src/request.c
|
|
+++ b/src/request.c
|
|
@@ -8,10 +8,39 @@
|
|
#include "log.h"
|
|
#include "sock_addr.h"
|
|
|
|
+#include <errno.h>
|
|
#include <limits.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
+#include <sys/statvfs.h>
|
|
|
|
+static size_t get_tempdirs_free_space(server *srv)
|
|
+{
|
|
+ int i;
|
|
+ int valid = 0;
|
|
+ size_t total = 0;
|
|
+ array *dirs = srv->srvconf.upload_tempdirs;
|
|
+
|
|
+ for (i = 0; i < (int)dirs->used; ++i) {
|
|
+ struct statvfs stat;
|
|
+ const char *name = ((data_string *)dirs->data[i])->value->ptr;
|
|
+ int ret = statvfs(name, &stat);
|
|
+
|
|
+ if (ret >= 0) {
|
|
+ size_t df = (size_t)(stat.f_bsize * stat.f_bfree);
|
|
+ total += df;
|
|
+ valid = 1;
|
|
+ }
|
|
+ else {
|
|
+ log_error_write(srv, __FILE__, __LINE__, "ssss",
|
|
+ "dir:", name,
|
|
+ "error:", strerror(errno));
|
|
+ }
|
|
+ }
|
|
+
|
|
+ return (valid) ? total : SSIZE_MAX;
|
|
+}
|
|
+
|
|
static int request_check_hostname(buffer *host) {
|
|
enum { DOMAINLABEL, TOPLABEL } stage = TOPLABEL;
|
|
size_t i;
|
|
@@ -928,6 +957,22 @@ int http_request_parse(server *srv, conn
|
|
if (!state.con_length_set) {
|
|
return http_request_header_line_invalid(srv, 411, "POST-request, but content-length missing -> 411");
|
|
}
|
|
+ /* content-length is larger than 64k */
|
|
+ if (con->request.content_length > 64*1024) {
|
|
+ size_t disk_free = get_tempdirs_free_space(srv);
|
|
+ if (con->request.content_length > disk_free) {
|
|
+ con->http_status = 413;
|
|
+ con->keep_alive = 0;
|
|
+
|
|
+ log_error_write(srv, __FILE__, __LINE__, "ssosos",
|
|
+ "not enough free space in tempdirs:",
|
|
+ "length =", (off_t) con->request.content_length,
|
|
+ "free =", (off_t) disk_free,
|
|
+ "-> 413");
|
|
+ return 0;
|
|
+ }
|
|
+ }
|
|
+
|
|
break;
|
|
default:
|
|
break;
|
|
--
|
|
2.21.0
|
|
|