aboutsummaryrefslogtreecommitdiffstats
path: root/src/tipideed/stream.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2025-04-02 16:58:27 +0000
committerLaurent Bercot <ska@appnovation.com>2025-04-02 16:58:27 +0000
commit58cdddb0a09e74fe6447c99a34dfa2ce7f8b5dee (patch)
treea57a9a41e257512f68b23a22d5958cb9ee7934ae /src/tipideed/stream.c
parent010875a69aec8d984db600e28539d2f902c74776 (diff)
downloadtipidee-58cdddb0a09e74fe6447c99a34dfa2ce7f8b5dee.tar.gz
Make answer content-length uint64-clean
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/tipideed/stream.c')
-rw-r--r--src/tipideed/stream.c10
1 files changed, 6 insertions, 4 deletions
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] ;