From bd5e3c02619988a420e496d28560056722e94683 Mon Sep 17 00:00:00 2001 From: nanahi <130121847+na-na-hi@users.noreply.github.com> Date: Mon, 21 Oct 2024 10:02:47 -0400 Subject: [PATCH] stream: allow max_size of 0 for stream_read_complete In this case, it returns a bstr of a length of 0 rather than error. --- stream/stream.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stream/stream.c b/stream/stream.c index 2e0ac39ecc..c45a6ae7eb 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -802,7 +802,7 @@ int stream_skip_bom(struct stream *s) // Read the rest of the stream into memory (current pos to EOF), and return it. // talloc_ctx: used as talloc parent for the returned allocation -// max_size: must be set to >0. If the file is larger than that, it is treated +// max_size: must be set to >=0. If the file is larger than that, it is treated // as error. This is a minor robustness measure. If the stream is // created with STREAM_ALLOW_PARTIAL_READ flag, partial result up to // max_size is returned instead. @@ -814,7 +814,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 <= 0 || max_size > STREAM_MAX_READ_SIZE) + if (max_size < 0 || max_size > STREAM_MAX_READ_SIZE) abort(); if (s->is_directory) return (struct bstr){NULL, 0};