summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKacper Michajłow <kasper93@gmail.com>2023-12-13 18:43:30 +0100
committerDudemanguy <random342@airmail.cc>2024-01-31 15:38:21 +0000
commita59b8edb96cbadbf61f30ec563bddee7701d984a (patch)
tree8e68a7c82fcf879449a85d220a57e9f00cb9456e
parentd90a5ff17a88cbda2ac64cccf1cd98456f2d0ab2 (diff)
downloadmpv-a59b8edb96cbadbf61f30ec563bddee7701d984a.tar.bz2
mpv-a59b8edb96cbadbf61f30ec563bddee7701d984a.tar.xz
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.
-rw-r--r--stream/stream.c2
-rw-r--r--stream/stream.h3
2 files changed, 4 insertions, 1 deletions
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