Skip to content

Commit ef983f5

Browse files
committed
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 <[email protected]> Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent d83d533 commit ef983f5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

libcontainer/cgroups/fscommon/utils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ func ParseUint(s string, base, bitSize int) (uint64, error) {
6060
// "io_service_bytes 1234" will be returned as "io_service_bytes", 1234.
6161
func ParseKeyValue(t string) (string, uint64, error) {
6262
key, val, ok := strings.Cut(t, " ")
63-
if !ok {
64-
return "", 0, fmt.Errorf("line %q is not in key value format", t)
63+
if !ok || key == "" || val == "" {
64+
return "", 0, fmt.Errorf(`line %q is not in "key value" format`, t)
6565
}
6666

6767
value, err := ParseUint(val, 10, 64)

0 commit comments

Comments
 (0)