mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
libct/cg/fscommon: ParseKeyValue: stricter check
It makes sense to report an error if a key or a value is empty, as we don't expect anything like this. Reported-by: Sebastiaan van Stijn <github@gone.nl> Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -60,8 +60,8 @@ func ParseUint(s string, base, bitSize int) (uint64, error) {
|
||||
// "io_service_bytes 1234" will be returned as "io_service_bytes", 1234.
|
||||
func ParseKeyValue(t string) (string, uint64, error) {
|
||||
key, val, ok := strings.Cut(t, " ")
|
||||
if !ok {
|
||||
return "", 0, fmt.Errorf("line %q is not in key value format", t)
|
||||
if !ok || key == "" || val == "" {
|
||||
return "", 0, fmt.Errorf(`line %q is not in "key value" format`, t)
|
||||
}
|
||||
|
||||
value, err := ParseUint(val, 10, 64)
|
||||
|
||||
Reference in New Issue
Block a user