eclipse-aaspe / server

C# based server for AASX packages
Other
72 stars 52 forks source link

Fix Thread-unsafe use of a static ICryptoTransform field #276

Closed Freezor closed 5 months ago

Freezor commented 5 months ago

Description

This pull request addresses the thread-unsafe use of a static ICryptoTransform field. The original code used a static instance of System.Security.Cryptography.SHA256, which is not thread-safe and could lead to potential issues when accessed concurrently by multiple threads. Code analysis

To resolve this, the static instance has been replaced with a method that creates a new instance of SHA256 whenever it is needed. This ensures that each thread operates on its own instance, thus maintaining thread safety.

Motivation and Context

This change is required to prevent potential thread safety issues that arise from the concurrent use of a shared SHA256 instance. By creating a new instance for each thread, we ensure the integrity and correctness of hash computations.

Fixes # (issue)

Type of change

How Has This Been Tested?

The changes have been tested by:

Screenshots (if appropriate):

Checklist: