Skip to content

Aircompressor cannot be used in insecure environments due to sun.misc.Unsafe #303

Description

@xxDark

... without copying.

public class AirCompressorVMCrash {

	public static void main(String[] args) {
		var deallocation = new ConcurrentLinkedQueue<Arena>();
		Thread.ofPlatform().daemon().start(() -> {
			do {
				Arena arena;
				if ((arena = deallocation.poll()) != null) arena.close();
			} while (true);
		});
		var compressor = new ZstdJavaCompressor();
		var input = createInput();
		var maxCompressedLength /* not 64-bit? */ = compressor.maxCompressedLength(/* not 64-bit? */ Math.toIntExact(input.byteSize()));
		do {
			var arena = Arena.ofShared();
			var output = arena.allocate(maxCompressedLength);
			deallocation.offer(arena);
			compressor.compress(input, output);
		} while (true);
	}

	private static MemorySegment createInput() {
		var b = new byte[655356];
		new SecureRandom().nextBytes(b);
		return MemorySegment.ofArray(b);
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions