From f5df9ccafa2c378165bde10f9a85a7b2e274b97b Mon Sep 17 00:00:00 2001 From: Gavin Halliday Date: Wed, 29 May 2024 14:26:34 +0100 Subject: [PATCH] HPCC-31956 Better error recovery when downgrading systems Signed-off-by: Gavin Halliday --- system/jlib/jlzw.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/system/jlib/jlzw.cpp b/system/jlib/jlzw.cpp index 2dbf48aca62..03f1344f510 100644 --- a/system/jlib/jlzw.cpp +++ b/system/jlib/jlzw.cpp @@ -804,10 +804,13 @@ void decompressToBuffer(MemoryBuffer & out, const void * src) void decompressToBuffer(MemoryBuffer & out, MemoryBuffer & in) { - bool compressed; + unsigned char method; size32_t srcLen; - in.read(compressed).read(srcLen); - if (compressed) + in.read(method).read(srcLen); + if (method > 1) + throw makeStringException(-1, "New compression format is not supported in this version"); + + if (method != 0) decompressToBuffer(out, in.readDirect(srcLen)); else out.append(srcLen, in.readDirect(srcLen));