Skip to content
This repository was archived by the owner on Nov 1, 2023. It is now read-only.

Commit 0112715

Browse files
authored
Ensure queue names don't get too long
1 parent 9af97f6 commit 0112715

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/ApiService/ApiService/onefuzzlib/ShrinkQueue.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
public record ShrinkEntry(Guid ShrinkId);
44

55
public sealed class ShrinkQueue {
6-
readonly string _baseId;
76
readonly IQueue _queueOps;
87
readonly ILogTracer _log;
98

@@ -17,18 +16,26 @@ public ShrinkQueue(Guid poolId, IQueue queueOps, ILogTracer log)
1716
: this(poolId.ToString("N"), queueOps, log) { }
1817

1918
private ShrinkQueue(string baseId, IQueue queueOps, ILogTracer log) {
20-
_baseId = baseId;
19+
var name = ShrinkQueueNamePrefix + baseId;
20+
21+
// queue names can be no longer than 64 characters
22+
// if we exceed that, trim off the end. we will still have
23+
// sufficient random chracters to stop collisions from happening
24+
if (name.Length > 64) {
25+
name = name[..64];
26+
}
27+
28+
QueueName = name;
2129
_queueOps = queueOps;
2230
_log = log;
2331
}
2432

2533
public static string ShrinkQueueNamePrefix => "to-shrink-";
2634

27-
public override string ToString() {
28-
return $"{ShrinkQueueNamePrefix}{_baseId}";
29-
}
35+
public override string ToString()
36+
=> QueueName;
3037

31-
public string QueueName => ToString();
38+
public string QueueName { get; }
3239

3340
public async Async.Task Clear() {
3441
await _queueOps.ClearQueue(QueueName, StorageType.Config);

0 commit comments

Comments
 (0)