serve docker: fix incorrect conversion between integer types

This commit is contained in:
albertony 2024-08-15 20:29:24 +02:00
parent 7261f47bd2
commit 4c488e7517

View File

@ -2,6 +2,7 @@ package docker
import ( import (
"fmt" "fmt"
"math"
"strings" "strings"
"github.com/rclone/rclone/cmd/mountlib" "github.com/rclone/rclone/cmd/mountlib"
@ -272,10 +273,22 @@ func getVFSOption(vfsOpt *vfscommon.Options, opt rc.Params, key string) (ok bool
err = getFVarP(&vfsOpt.Umask, opt, key) err = getFVarP(&vfsOpt.Umask, opt, key)
case "uid": case "uid":
intVal, err = opt.GetInt64(key) intVal, err = opt.GetInt64(key)
if err == nil {
if intVal >= 0 && intVal <= math.MaxUint32 {
vfsOpt.UID = uint32(intVal) vfsOpt.UID = uint32(intVal)
} else {
err = fmt.Errorf("key %q (%v) overflows uint32", key, intVal)
}
}
case "gid": case "gid":
intVal, err = opt.GetInt64(key) intVal, err = opt.GetInt64(key)
vfsOpt.GID = uint32(intVal) if err == nil {
if intVal >= 0 && intVal <= math.MaxUint32 {
vfsOpt.UID = uint32(intVal)
} else {
err = fmt.Errorf("key %q (%v) overflows uint32", key, intVal)
}
}
// non-vfs options // non-vfs options
default: default: