aboutsummaryrefslogtreecommitdiffstats
path: root/slowcgi.c
diff options
context:
space:
mode:
authorblambert2013-09-06 07:36:03 +0000
committerWynn Wolf Arbor2020-05-24 12:33:55 +0200
commit1d32e36cce95a1f1a68aae33620b208aa0a65105 (patch)
tree79f6f1d2ee2db1dffb9a648f5aa0020203aaa5ce /slowcgi.c
parent19ab07d4020c9d4c2a2503dd05440f0b9227708f (diff)
downloadslowcgi-1d32e36cce95a1f1a68aae33620b208aa0a65105.tar.gz
Use the correct buffer size for memory allocation and reads.
okay florian@
Diffstat (limited to 'slowcgi.c')
-rw-r--r--slowcgi.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/slowcgi.c b/slowcgi.c
index e8636fa..5664c03 100644
--- a/slowcgi.c
+++ b/slowcgi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: slowcgi.c,v 1.7 2013/08/30 07:10:26 blambert Exp $ */
+/* $OpenBSD: slowcgi.c,v 1.8 2013/09/06 07:36:03 blambert Exp $ */
/*
* Copyright (c) 2013 David Gwynne <dlg@openbsd.org>
* Copyright (c) 2013 Florian Obser <florian@openbsd.org>
@@ -39,7 +39,12 @@
#define TIMEOUT_DEFAULT 120
#define SLOWCGI_USER "www"
-#define FCGI_RECORD_SIZE 64*1024
+
+#define FCGI_CONTENT_SIZE 65535
+#define FCGI_PADDING_SIZE 255
+#define FCGI_RECORD_SIZE \
+ (sizeof(struct fcgi_record_header) + FCGI_CONTENT_SIZE + FCGI_PADDING_SIZE)
+
#define STDOUT_DONE 1
#define STDERR_DONE 2
#define SCRIPT_DONE 4
@@ -84,8 +89,7 @@ struct fcgi_record_header {
struct fcgi_response {
TAILQ_ENTRY(fcgi_response) entry;
- uint8_t data[FCGI_RECORD_SIZE + sizeof(struct
- fcgi_record_header)];
+ uint8_t data[FCGI_RECORD_SIZE];
size_t data_pos;
size_t data_len;
};
@@ -833,7 +837,7 @@ script_in(int fd, struct event *ev, struct client *c, uint8_t type)
header->reserved = 0;
n = read(fd, resp->data + sizeof(struct fcgi_record_header),
- FCGI_RECORD_SIZE);
+ FCGI_CONTENT_SIZE);
if (n == -1) {
switch (errno) {