mirror of https://github.com/XTLS/Xray-core
REALITY config: Return error when short id is too long (#5276)
Closes https://github.com/XTLS/Xray-core/issues/5273 --------- Co-authored-by: 风扇滑翔翼 <Fangliding.fshxy@outlook.com>pull/5315/head
parent
412bc17c12
commit
1a32d18c16
|
|
@ -628,6 +628,9 @@ func (c *REALITYConfig) Build() (proto.Message, error) {
|
|||
}
|
||||
config.ShortIds = make([][]byte, len(c.ShortIds))
|
||||
for i, s := range c.ShortIds {
|
||||
if len(s) > 16 {
|
||||
return nil, errors.New(`too long "shortIds[`, i, `]": `, s)
|
||||
}
|
||||
config.ShortIds[i] = make([]byte, 8)
|
||||
if _, err = hex.Decode(config.ShortIds[i], []byte(s)); err != nil {
|
||||
return nil, errors.New(`invalid "shortIds[`, i, `]": `, s)
|
||||
|
|
@ -679,6 +682,9 @@ func (c *REALITYConfig) Build() (proto.Message, error) {
|
|||
if len(c.ShortIds) != 0 {
|
||||
return nil, errors.New(`non-empty "shortIds", please use "shortId" instead`)
|
||||
}
|
||||
if len(c.ShortIds) > 16 {
|
||||
return nil, errors.New(`too long "shortId": `, c.ShortId)
|
||||
}
|
||||
config.ShortId = make([]byte, 8)
|
||||
if _, err = hex.Decode(config.ShortId, []byte(c.ShortId)); err != nil {
|
||||
return nil, errors.New(`invalid "shortId": `, c.ShortId)
|
||||
|
|
|
|||
Loading…
Reference in New Issue