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.
This commit is contained in:
nanahi 2024-10-21 10:02:47 -04:00 committed by Avi Halachmi
parent 2af0b0b34b
commit bd5e3c0261
1 changed files with 2 additions and 2 deletions

View File

@ -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};