From 5583831c40d51e5f63540ccfcda71b678564c21b Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Sat, 24 Aug 2024 10:50:44 +0200 Subject: [PATCH] zstd: Fix minetest.decompress lockup when data ends too early --- src/serialization.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/serialization.cpp b/src/serialization.cpp index 4134126ca..0319b0159 100644 --- a/src/serialization.cpp +++ b/src/serialization.cpp @@ -262,6 +262,8 @@ void decompressZstd(std::istream &is, std::ostream &os) is.read(input_buffer, bufsize); input.size = is.gcount(); input.pos = 0; + if (input.size == 0) + throw SerializationError("decompressZstd: data ended too early"); } ret = ZSTD_decompressStream(stream.get(), &output, &input);