mirror of
https://github.com/containers/podman.git
synced 2025-08-16 04:15:29 +08:00
use slices.Clone instead of assignment
Fixes #24267 This commit replaces a potentially unsafe slice-assignment with a call to `slices.Clone`. This could prevent a bug where `saveCommand` and `loadCommand` could end up sharing an underlying array if `parentFlags` has a cap > it's len. Signed-off-by: Zachary Hanham <z.hanham00@gmail.com>
This commit is contained in:
@ -13,6 +13,7 @@ import (
|
|||||||
"os/user"
|
"os/user"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"slices"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
@ -803,7 +804,8 @@ func Transfer(ctx context.Context, source entities.ImageScpOptions, dest entitie
|
|||||||
// TransferRootless creates new podman processes using exec.Command and sudo, transferring images between the given source and destination users
|
// TransferRootless creates new podman processes using exec.Command and sudo, transferring images between the given source and destination users
|
||||||
func transferRootless(source entities.ImageScpOptions, dest entities.ImageScpOptions, podman string, parentFlags []string) error {
|
func transferRootless(source entities.ImageScpOptions, dest entities.ImageScpOptions, podman string, parentFlags []string) error {
|
||||||
var cmdSave *exec.Cmd
|
var cmdSave *exec.Cmd
|
||||||
saveCommand, loadCommand := parentFlags, parentFlags
|
saveCommand := slices.Clone(parentFlags)
|
||||||
|
loadCommand := slices.Clone(parentFlags)
|
||||||
saveCommand = append(saveCommand, []string{"save"}...)
|
saveCommand = append(saveCommand, []string{"save"}...)
|
||||||
loadCommand = append(loadCommand, []string{"load"}...)
|
loadCommand = append(loadCommand, []string{"load"}...)
|
||||||
if source.Quiet {
|
if source.Quiet {
|
||||||
|
Reference in New Issue
Block a user