Skip to content

Commit 2752e1b

Browse files
authored
Fix array length Fixes #45632 (#46653)
Fixes #45632 #42775 changed the hash function we used from one that generates a 64-byte hash to one that generates an 8-byte hash. We were only actually using 16 bytes of the hash, but 16 bytes of an 8-byte hash is a source array not long enough error. This upgrades to a 16-byte hash from the same hash family.
1 parent 755effb commit 2752e1b

File tree

1 file changed

+3
-1
lines changed
  • src/Cli/Microsoft.DotNet.Cli.Utils

1 file changed

+3
-1
lines changed

src/Cli/Microsoft.DotNet.Cli.Utils/Uuid.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Diagnostics;
45
using System.IO.Hashing;
56

67
namespace Microsoft.DotNet.Cli.Utils
@@ -27,7 +28,8 @@ public static Guid Create(string name)
2728
Array.Copy(namespaceBytes, streamToHash, namespaceBytes.Length);
2829
Array.Copy(nameBytes, 0, streamToHash, namespaceBytes.Length, nameBytes.Length);
2930

30-
var hashResult = XxHash3.Hash(streamToHash); // This is just used for generating a named pipe so we don't need a cryptographic hash
31+
var hashResult = XxHash128.Hash(streamToHash); // This is just used for generating a named pipe so we don't need a cryptographic hash
32+
Debug.Assert(hashResult.Length >= 16);
3133

3234
var res = new byte[16];
3335

0 commit comments

Comments
 (0)