From a4a4c90ed386c783bbb0e6f39b9e53fbe8a4a7ad Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Thu, 30 Nov 2017 14:58:36 -0500 Subject: [PATCH] Use strconv.Atoi for uid/gid parsing This follows the same logic that runc uses for parsing uid/gid values. Signed-off-by: Michael Crosby --- oci/spec_opts_unix.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/oci/spec_opts_unix.go b/oci/spec_opts_unix.go index b17ca3216..3a07f377e 100644 --- a/oci/spec_opts_unix.go +++ b/oci/spec_opts_unix.go @@ -101,7 +101,7 @@ func WithImageConfig(image Image) SpecOpts { parts := strings.Split(config.User, ":") switch len(parts) { case 1: - v, err := strconv.ParseUint(parts[0], 0, 10) + v, err := strconv.Atoi(parts[0]) if err != nil { // if we cannot parse as a uint they try to see if it is a username if err := WithUsername(config.User)(ctx, client, c, s); err != nil { @@ -113,13 +113,13 @@ func WithImageConfig(image Image) SpecOpts { return err } case 2: - v, err := strconv.ParseUint(parts[0], 0, 10) + v, err := strconv.Atoi(parts[0]) if err != nil { - return err + return errors.Wrapf(err, "parse uid %s", parts[0]) } uid := uint32(v) - if v, err = strconv.ParseUint(parts[1], 0, 10); err != nil { - return err + if v, err = strconv.Atoi(parts[1]); err != nil { + return errors.Wrapf(err, "parse gid %s", parts[1]) } gid := uint32(v) s.Process.User.UID, s.Process.User.GID = uid, gid