mirror of
https://github.com/containers/podman.git
synced 2025-12-12 01:38:04 +08:00
vendor: update common and buildah
vendor the following dependencies: - https://github.com/containers/common/pull/2375 - https://github.com/containers/buildah/pull/6074 Closes: https://github.com/containers/podman/issues/25634 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
7
vendor/github.com/containers/common/libnetwork/internal/util/create.go
generated
vendored
7
vendor/github.com/containers/common/libnetwork/internal/util/create.go
generated
vendored
@@ -39,6 +39,13 @@ func CommonNetworkCreate(n NetUtil, network *types.Network) error {
|
||||
network.NetworkInterface = name
|
||||
}
|
||||
}
|
||||
|
||||
// Validate interface name if specified
|
||||
if network.NetworkInterface != "" {
|
||||
if err := ValidateInterfaceName(network.NetworkInterface); err != nil {
|
||||
return fmt.Errorf("network interface name %s invalid: %w", network.NetworkInterface, err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
22
vendor/github.com/containers/common/libnetwork/internal/util/validate.go
generated
vendored
22
vendor/github.com/containers/common/libnetwork/internal/util/validate.go
generated
vendored
@@ -4,6 +4,8 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
"unicode"
|
||||
|
||||
"github.com/containers/common/libnetwork/types"
|
||||
"github.com/containers/common/libnetwork/util"
|
||||
@@ -159,3 +161,23 @@ func validatePerNetworkOpts(network *types.Network, netOpts *types.PerNetworkOpt
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ValidateInterfaceName validates the interface name based on the following rules:
|
||||
// 1. The name must be less than MaxInterfaceNameLength characters
|
||||
// 2. The name must not be "." or ".."
|
||||
// 3. The name must not contain / or : or any whitespace characters
|
||||
// ref to https://github.com/torvalds/linux/blob/81e4f8d68c66da301bb881862735bd74c6241a19/include/uapi/linux/if.h#L33C18-L33C20
|
||||
func ValidateInterfaceName(ifName string) error {
|
||||
if len(ifName) > types.MaxInterfaceNameLength {
|
||||
return fmt.Errorf("interface name is too long: interface names must be %d characters or less: %w", types.MaxInterfaceNameLength, types.ErrInvalidArg)
|
||||
}
|
||||
if ifName == "." || ifName == ".." {
|
||||
return fmt.Errorf("interface name is . or ..: %w", types.ErrInvalidArg)
|
||||
}
|
||||
if strings.ContainsFunc(ifName, func(r rune) bool {
|
||||
return r == '/' || r == ':' || unicode.IsSpace(r)
|
||||
}) {
|
||||
return fmt.Errorf("interface name contains / or : or whitespace characters: %w", types.ErrInvalidArg)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
3
vendor/github.com/containers/common/libnetwork/types/define.go
generated
vendored
3
vendor/github.com/containers/common/libnetwork/types/define.go
generated
vendored
@@ -30,4 +30,7 @@ var (
|
||||
// NotHexRegex is a regular expression to check if a string is
|
||||
// a hexadecimal string.
|
||||
NotHexRegex = regexp.Delayed(`[^0-9a-fA-F]`)
|
||||
|
||||
// MaxInterfaceNameLength is the maximum length of a network interface name
|
||||
MaxInterfaceNameLength = 15
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user