diff --git a/src/libs/gocmdbridge/server/cmdbridge.go b/src/libs/gocmdbridge/server/cmdbridge.go index 2d993dd7571..ee60f425e90 100644 --- a/src/libs/gocmdbridge/server/cmdbridge.go +++ b/src/libs/gocmdbridge/server/cmdbridge.go @@ -11,6 +11,8 @@ import ( "path/filepath" "reflect" "runtime" + "slices" + "strings" "sync" "syscall" @@ -402,7 +404,12 @@ func processCommand(watcher *WatcherHandler, cmd command, out chan<- []byte) { func sendEnvironment(out chan<- []byte) { - env := os.Environ() + // Delete all entries without a valid key. + env := slices.DeleteFunc(os.Environ(), func(s string) bool { + trimmed := strings.TrimSpace(s) + return len(trimmed) == 0 || trimmed[0] == '=' + }) + result, _ := cbor.Marshal(environment{ Type: "environment", Id: -1, diff --git a/src/plugins/remotelinux/linuxdevice.cpp b/src/plugins/remotelinux/linuxdevice.cpp index 534e7740491..705891e3900 100644 --- a/src/plugins/remotelinux/linuxdevice.cpp +++ b/src/plugins/remotelinux/linuxdevice.cpp @@ -826,7 +826,7 @@ CommandLine SshProcessInterfacePrivate::fullLocalCommandLine() const const Environment &env = q->m_setup.m_environment; env.forEachEntry([&](const QString &key, const QString &value, bool enabled) { - if (enabled) + if (enabled && !key.trimmed().isEmpty()) inner.addArgs(key + "='" + env.expandVariables(value) + '\'', CommandLine::Raw); });