mirror of
https://github.com/distribution/distribution.git
synced 2025-09-24 12:37:00 +00:00
Check length of input in WithName
There is a constraint on the length of the name in a reference, so WithName should be checking this instead of potentially creating a reference that doesn't comply with the rules. Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
This commit is contained in:
@@ -204,6 +204,9 @@ func ParseNamed(s string) (Named, error) {
|
||||
// WithName returns a named object representing the given string. If the input
|
||||
// is invalid ErrReferenceInvalidFormat will be returned.
|
||||
func WithName(name string) (Named, error) {
|
||||
if len(name) > NameTotalLengthMax {
|
||||
return nil, ErrNameTooLong
|
||||
}
|
||||
if !anchoredNameRegexp.MatchString(name) {
|
||||
return nil, ErrReferenceInvalidFormat
|
||||
}
|
||||
|
Reference in New Issue
Block a user