Skip to content

Commit

Permalink
Name-fields support: validate names are within length constraints.
Browse files Browse the repository at this point in the history
  • Loading branch information
diagprov committed May 31, 2019
1 parent 8c19eb1 commit 25e1141
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions types.go
Expand Up @@ -19,6 +19,9 @@ const (

IDLenHex = IDLen * 2
KeyLenHex = KeyLen * 2

NameMinLen = 1
NameMaxLen = 255
)

// Command is a command sent by C2 to a client.
Expand Down Expand Up @@ -70,6 +73,10 @@ func IsValidName(name string) error {
if !utf8.ValidString(name) {
return fmt.Errorf("Name is not a valid UTF-8 string")
}
namelen := len(name)
if namelen < NameMinLen || namelen > NameMaxLen {
return fmt.Errorf("Name length is invalid, names are between %d and %d characters", NameMinLen, NameMaxLen)
}
return nil
}

Expand Down

0 comments on commit 25e1141

Please sign in to comment.