diff options
author | 2013-09-06 07:36:03 +0000 | |
---|---|---|
committer | 2013-09-06 07:36:03 +0000 | |
commit | 0ee0284d29009f58ce56655d2bc7a21de3010e54 (patch) | |
tree | 261dd9a246f76012de1175b4aa9f4e9efae7d0df | |
parent | gcc4 has phased out -W in favor of -Wextra. Teach gcc3 to recognize -Wextra (diff) | |
download | wireguard-openbsd-0ee0284d29009f58ce56655d2bc7a21de3010e54.tar.xz wireguard-openbsd-0ee0284d29009f58ce56655d2bc7a21de3010e54.zip |
Use the correct buffer size for memory allocation and reads.
okay florian@
-rw-r--r-- | usr.sbin/slowcgi/slowcgi.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/usr.sbin/slowcgi/slowcgi.c b/usr.sbin/slowcgi/slowcgi.c index e8636fa408c..5664c03aa90 100644 --- a/usr.sbin/slowcgi/slowcgi.c +++ b/usr.sbin/slowcgi/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) { |