peschkaj / NewYouID

UUIDv7 generator for .NET 5
MIT License
3 stars 0 forks source link

Mask computed values to ensure they are in range #2

Closed peschkaj closed 3 years ago

peschkaj commented 3 years ago

In the NextId method, there is a chance that the code assigning to high could contain values of subsec_a that overflow and overwrite portions of unixts. Both unixts and subsec_a should be recoverable from within the UUID.

ulong high = (unixts << 28) | (subsec_a << 16) | (Version << 12) | (_counter & CounterMask);

The preferred option here would be to mask all values to the appropriate size before creating any high/low values.

peschkaj commented 3 years ago

Closed in ddd4a26b1c76c33f73bc2daf0bb4b17a94cee727