Compression fails in Adler32 on a machine that supports SSE3, but not SSSE3 #514

Closed
opened 2026-01-29 22:13:09 +00:00 by claunia · 3 comments
Owner

Originally created by @emz00 on GitHub (Mar 30, 2022).

We're using MongoDB.Driver, which indirectly calls SharpCompress and it fails on a machine with a AMD Opteron(tm) Processor 6176 SE CPU, which supports SSE3, but not SSSE3.

System.PlatformNotSupportedException: Operation is not supported on this platform.
   at System.Runtime.Intrinsics.X86.Ssse3.MultiplyAddAdjacent(Vector128`1 left, Vector128`1 right)
   at SharpCompress.Algorithms.Adler32.CalculateSse(UInt32 adler, ReadOnlySpan`1 buffer)
   at SharpCompress.Algorithms.Adler32.Calculate(UInt32 adler, ReadOnlySpan`1 buffer)
   at SharpCompress.Compressors.Deflate.ZlibCodec.read_buf(Byte[] buf, Int32 start, Int32 size)
   at SharpCompress.Compressors.Deflate.DeflateManager._fillWindow()
   at SharpCompress.Compressors.Deflate.DeflateManager.DeflateSlow(FlushType flush)
   at SharpCompress.Compressors.Deflate.DeflateManager.Deflate(FlushType flush)
   at SharpCompress.Compressors.Deflate.ZlibBaseStream.Write(Byte[] buffer, Int32 offset, Int32 count)
   at MongoDB.Bson.IO.ByteBufferStream.EfficientCopyTo(Stream destination)

This seems to be because the version of Adler32 used by SharpCompress checks for SSE3 and then uses SSSE3:

            if (Sse3.IsSupported && buffer.Length >= MinBufferSize)
            {
                return CalculateSse(adler, buffer); // using SSSE3
            }

This is already fixed in the latest version: https://github.com/SixLabors/ImageSharp/blob/main/src/ImageSharp/Compression/Zlib/Adler32.cs

That checks Ssse3.IsSupported - could you please upgrade to it? That would also fix #645.

Originally created by @emz00 on GitHub (Mar 30, 2022). We're using MongoDB.Driver, which indirectly calls SharpCompress and it fails on a machine with a AMD Opteron(tm) Processor 6176 SE CPU, which supports SSE3, but not SSSE3. ``` System.PlatformNotSupportedException: Operation is not supported on this platform. at System.Runtime.Intrinsics.X86.Ssse3.MultiplyAddAdjacent(Vector128`1 left, Vector128`1 right) at SharpCompress.Algorithms.Adler32.CalculateSse(UInt32 adler, ReadOnlySpan`1 buffer) at SharpCompress.Algorithms.Adler32.Calculate(UInt32 adler, ReadOnlySpan`1 buffer) at SharpCompress.Compressors.Deflate.ZlibCodec.read_buf(Byte[] buf, Int32 start, Int32 size) at SharpCompress.Compressors.Deflate.DeflateManager._fillWindow() at SharpCompress.Compressors.Deflate.DeflateManager.DeflateSlow(FlushType flush) at SharpCompress.Compressors.Deflate.DeflateManager.Deflate(FlushType flush) at SharpCompress.Compressors.Deflate.ZlibBaseStream.Write(Byte[] buffer, Int32 offset, Int32 count) at MongoDB.Bson.IO.ByteBufferStream.EfficientCopyTo(Stream destination) ``` This seems to be because the version of Adler32 used by SharpCompress checks for SSE3 and then uses SSSE3: ``` if (Sse3.IsSupported && buffer.Length >= MinBufferSize) { return CalculateSse(adler, buffer); // using SSSE3 } ``` This is already fixed in the latest version: https://github.com/SixLabors/ImageSharp/blob/main/src/ImageSharp/Compression/Zlib/Adler32.cs That checks `Ssse3.IsSupported` - could you please upgrade to it? That would also fix #645.
claunia added the bugup for grabs labels 2026-01-29 22:13:09 +00:00
Author
Owner

@emz00 commented on GitHub (Mar 30, 2022):

Our version of MongoDB driver is using SharpCompress 0.23 which has a path traversal vulnerability and we cannot upgrade to a patched version due to this issue.

@emz00 commented on GitHub (Mar 30, 2022): Our version of MongoDB driver is using SharpCompress 0.23 which has a [path traversal vulnerability](https://github.com/advisories/GHSA-jp7f-grcv-6mjf) and we cannot upgrade to a patched version due to this issue.
Author
Owner

@adamhathcock commented on GitHub (Mar 30, 2022):

I would accept a PR. Not sure when I'll have time myself

@adamhathcock commented on GitHub (Mar 30, 2022): I would accept a PR. Not sure when I'll have time myself
Author
Owner

@adamhathcock commented on GitHub (Mar 30, 2022):

Fix released in https://www.nuget.org/packages/SharpCompress/0.31.0

@adamhathcock commented on GitHub (Mar 30, 2022): Fix released in https://www.nuget.org/packages/SharpCompress/0.31.0
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#514