Return err when short id is too long (#5276)

风扇滑翔翼 2025-11-15 10:00:32 +08:00 committed by GitHub
parent b030a94435
commit a36d36b6e5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 0 deletions

View File

@ -629,6 +629,9 @@ func (c *REALITYConfig) Build() (proto.Message, error) {
config.ShortIds = make([][]byte, len(c.ShortIds))
for i, s := range c.ShortIds {
config.ShortIds[i] = make([]byte, 8)
if len(s) > 16 {
return nil, errors.New(`invalid "shortIds[`, i, `]": `, s)
}
if _, err = hex.Decode(config.ShortIds[i], []byte(s)); err != nil {
return nil, errors.New(`invalid "shortIds[`, i, `]": `, s)
}