Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

serve docker: fix incorrect conversion between integer types

albertony4c488e7517a6
diff --git a/cmd/serve/docker/options.go b/cmd/serve/docker/options.go
index ef598ebb0..9779828f8 100644
--- a/cmd/serve/docker/options.go
+++ b/cmd/serve/docker/options.go
@@ -2,6 +2,7 @@ package docker
import (
"fmt"
+ "math"
"strings"
"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)
case "uid":
intVal, err = opt.GetInt64(key)
- vfsOpt.UID = 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)
+ }
+ }
case "gid":
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
default: