From e4793968561605c13b5dc6e2c99dabb4170f8310 Mon Sep 17 00:00:00 2001 From: Torsten Krah Date: Wed, 12 Jun 2024 18:49:58 +0200 Subject: [PATCH] Fix possible CME while replacing properties Fixes #2274 --- .../dockerjava/core/DefaultDockerClientConfig.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docker-java-core/src/main/java/com/github/dockerjava/core/DefaultDockerClientConfig.java b/docker-java-core/src/main/java/com/github/dockerjava/core/DefaultDockerClientConfig.java index 8011a2a5e..7088faa57 100644 --- a/docker-java-core/src/main/java/com/github/dockerjava/core/DefaultDockerClientConfig.java +++ b/docker-java-core/src/main/java/com/github/dockerjava/core/DefaultDockerClientConfig.java @@ -5,6 +5,8 @@ import com.github.dockerjava.api.model.AuthConfigurations; import com.github.dockerjava.core.NameParser.HostnameReposName; import com.github.dockerjava.core.NameParser.ReposTag; + +import java.util.Map.Entry; import java.util.Optional; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.SystemUtils; @@ -128,9 +130,11 @@ private static Properties loadIncludedDockerProperties(Properties systemProperti } private static void replaceProperties(Properties properties, Properties replacements) { - for (Object objectKey : properties.keySet()) { - String key = objectKey.toString(); - properties.setProperty(key, replaceProperties(properties.getProperty(key), replacements)); + for (Entry next : properties.entrySet()) { + final String key = next.getKey().toString(); + // no next.getValue here because it does not have the same semantics as getProperty (defaults handling) + final String value = properties.getProperty(key); + next.setValue(replaceProperties(value, replacements)); } }