From a59b8edb96cbadbf61f30ec563bddee7701d984a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Wed, 13 Dec 2023 18:43:30 +0100 Subject: [PATCH] stream: increase max_size to INT_MAX minus padding No need to magic number limit, we can support up to INT_MAX with current code. Which should be more than enough. --- stream/stream.c | 2 +- stream/stream.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/stream/stream.c b/stream/stream.c index dd67825dd5..43a7f51a60 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -803,7 +803,7 @@ int stream_skip_bom(struct stream *s) struct bstr stream_read_complete(struct stream *s, void *talloc_ctx, int max_size) { - if (max_size > 1000000000) + if (max_size <= 0 || max_size > STREAM_MAX_READ_SIZE) abort(); int bufsize; diff --git a/stream/stream.h b/stream/stream.h index 423ba12d91..58b55e1a43 100644 --- a/stream/stream.h +++ b/stream/stream.h @@ -32,6 +32,9 @@ // it's guaranteed that you can seek back by <= of this size again. #define STREAM_BUFFER_SIZE 2048 +// Maximum size of a complete read. +#define STREAM_MAX_READ_SIZE (INT_MAX - 1) + // flags for stream_open_ext (this includes STREAM_READ and STREAM_WRITE) // stream->mode