Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Truncate IpAddresses of IdentitySession. #20819

Merged
merged 2 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ public class IdentitySessionConsts

public static int MaxClientIdLength { get; set; } = 64;

public static int MaxIpAddressesLength { get; set; } = 256;
public static int MaxIpAddressesLength { get; set; } = 2048;
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,22 @@ public IEnumerable<string> GetIpAddresses()
private static string JoinAsString(IEnumerable<string> list)
{
var serialized = string.Join(",", list);
return serialized.IsNullOrWhiteSpace() ? null : serialized;
if (serialized.IsNullOrWhiteSpace())
{
return null;
}

while (serialized.Length > IdentitySessionConsts.MaxIpAddressesLength)
{
var lastCommaIndex = serialized.IndexOf(',');
if (lastCommaIndex < 0)
{
return serialized;
}
serialized = serialized.Substring(lastCommaIndex + 1);
}

return serialized;
}

private string[] GetArrayFromString(string str)
Expand Down
Loading