integ/base/lighttpd/lighttpd-1.4.35/check-content-length.patch
Scott Little bab9bb6b69 Internal restructuring of stx-integ
Create new directories:
   ceph
   config
   config-files
   filesystem
   kernel
   kernel/kernel-modules
   ldap
   logging
   strorage-drivers
   tools
   utilities
   virt

Retire directories:
   connectivity
   core
   devtools
   support
   extended

Delete two packages:
   tgt
   irqbalance

Relocated packages:
   base/
      dhcp
      initscripts
      libevent
      lighttpd
      linuxptp
      memcached
      net-snmp
      novnc
      ntp
      openssh
      pam
      procps
      sanlock
      shadow
      sudo
      systemd
      util-linux
      vim
      watchdog

   ceph/
      python-cephclient

   config/
      facter
      puppet-4.8.2
      puppet-modules

   filesystem/
      e2fsprogs
      nfs-utils
      nfscheck

   kernel/
      kernel-std
      kernel-rt

   kernel/kernel-modules/
      mlnx-ofa_kernel

   ldap/
      nss-pam-ldapd
      openldap

   logging/
      syslog-ng
      logrotate

   networking/
      lldpd
      iproute
      mellanox
      python-ryu
      mlx4-config

   python/
      python-2.7.5
      python-django
      python-gunicorn
      python-setuptools
      python-smartpm
      python-voluptuous

   security/
      shim-signed
      shim-unsigned
      tboot

   strorage-drivers/
      python-3parclient
      python-lefthandclient

   virt/
      cloud-init
      libvirt
      libvirt-python
      qemu

   tools/
      storage-topology
      vm-topology

   utilities/
      tis-extensions
      namespace-utils
      nova-utils
      update-motd

Change-Id: I37ade764d873c701b35eac5881eb40412ba64a86
Story: 2002801
Task: 22687
Signed-off-by: Scott Little <scott.little@windriver.com>
2018-08-01 10:06:31 -04:00

87 lines
2.1 KiB
Diff

From b9410d967faf627d72fc5496a4c2e7aab879b7aa Mon Sep 17 00:00:00 2001
From: Giao Le <giao.le@windriver.com>
Date: Wed, 19 Oct 2016 15:06:17 -0400
Subject: [PATCH 1/1] check
---
src/request.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/src/request.c b/src/request.c
index a2de944..857076c 100644
--- a/src/request.c
+++ b/src/request.c
@@ -12,6 +12,39 @@
#include <stdio.h>
#include <ctype.h>
+#include <sys/statvfs.h>
+#include <string.h>
+#include <errno.h>
+#include <limits.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;
@@ -409,6 +442,7 @@ static int request_uri_is_valid_char(unsigned char c) {
return 1;
}
+
int http_request_parse(server *srv, connection *con) {
char *uri = NULL, *proto = NULL, *method = NULL, con_length_set;
int is_key = 1, key_len = 0, is_ws_after_key = 0, in_folding;
@@ -1294,6 +1328,21 @@ int http_request_parse(server *srv, connection *con) {
return 0;
}
+ /* 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;
--
1.8.3.1