diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2025-04-02 16:58:27 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska@appnovation.com> | 2025-04-02 16:58:27 +0000 |
| commit | 58cdddb0a09e74fe6447c99a34dfa2ce7f8b5dee (patch) | |
| tree | a57a9a41e257512f68b23a22d5958cb9ee7934ae /src | |
| parent | 010875a69aec8d984db600e28539d2f902c74776 (diff) | |
| download | tipidee-58cdddb0a09e74fe6447c99a34dfa2ce7f8b5dee.tar.gz | |
Make answer content-length uint64-clean
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/tipideed/cgi.c | 9 | ||||
| -rw-r--r-- | src/tipideed/stream.c | 10 |
2 files changed, 11 insertions, 8 deletions
diff --git a/src/tipideed/cgi.c b/src/tipideed/cgi.c index 905792c..316e44f 100644 --- a/src/tipideed/cgi.c +++ b/src/tipideed/cgi.c @@ -6,6 +6,7 @@ #include <errno.h> #include <signal.h> +#include <skalibs/uint64.h> #include <skalibs/gccattributes.h> #include <skalibs/posixplz.h> #include <skalibs/types.h> @@ -179,8 +180,8 @@ static inline int do_cgi (tipidee_rql *rql, char const *docroot, char const *con char const *location ; char const *contentlength ; char const *statusfield ; + uint64_t rbodylen = 0 ; unsigned int status = 0 ; - size_t rbodylen = 0 ; int r ; tipidee_headers hdr ; char hdrbuf[4096] ; @@ -270,7 +271,7 @@ static inline int do_cgi (tipidee_rql *rql, char const *docroot, char const *con contentlength = tipidee_headers_search(&hdr, "Content-Length") ; if (contentlength) { - if (!size0_scan(contentlength, &rbodylen)) + if (!uint640_scan(contentlength, &rbodylen)) die502x(rql, 2, docroot, "cgi ", argv[0], " returned an invalid ", "Content-Length", " header") ; } if (statusfield) @@ -332,8 +333,8 @@ static inline int do_cgi (tipidee_rql *rql, char const *docroot, char const *con if (contentlength) { - char fmt[SIZE_FMT] ; - fmt[size_fmt(fmt, rbodylen)] = 0 ; + char fmt[UINT64_FMT] ; + fmt[uint64_fmt(fmt, rbodylen)] = 0 ; buffer_putsnoflush(buffer_1, "Content-Length: ") ; buffer_putsnoflush(buffer_1, fmt) ; buffer_putnoflush(buffer_1, "\r\n", 2) ; diff --git a/src/tipideed/stream.c b/src/tipideed/stream.c index 04faf21..a0bdbd2 100644 --- a/src/tipideed/stream.c +++ b/src/tipideed/stream.c @@ -10,7 +10,9 @@ #include <fcntl.h> #include <stdint.h> #include <unistd.h> +#include <limits.h> +#include <skalibs/uint64.h> #include <skalibs/allreadwrite.h> #include <skalibs/strerr.h> #include <skalibs/tai.h> @@ -22,7 +24,7 @@ struct fixed_info_s { int fd ; - size_t n ; + uint64_t n ; } ; static int fixed_getfd (void *b) @@ -36,7 +38,7 @@ static ssize_t fixed_get (void *b) struct fixed_info_s *si = b ; while (si->n) { - ssize_t r = sanitize_read(splice(si->fd, 0, 1, 0, si->n, SPLICE_F_NONBLOCK)) ; + ssize_t r = sanitize_read(splice(si->fd, 0, 1, 0, si->n > SSIZE_MAX ? SSIZE_MAX : si->n, SPLICE_F_NONBLOCK)) ; if (r == -1) break ; if (!r) return 0 ; si->n -= r ; @@ -44,7 +46,7 @@ static ssize_t fixed_get (void *b) return si->n ? -1 : 1 ; } -void stream_fixed (int fd, size_t n, char const *fn) +void stream_fixed (int fd, uint64_t n, char const *fn) { tain deadline ; struct fixed_info_s si = { .fd = fd, .n = n } ; @@ -87,7 +89,7 @@ void stream_infinite (int fd, char const *fn) #include "tipideed-internal.h" -void stream_fixed (int fd, size_t n, char const *fn) +void stream_fixed (int fd, uint64_t n, char const *fn) { tain deadline ; struct iovec v[2] ; |
