From 8d3090665d5de9a12c6eb6933a959a8593dd4118 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 27 Sep 2024 16:53:08 +0200 Subject: [PATCH] Do not allow StorageEntry to be subverted Perform a defensive clone on {insert,put}Entry(), so that these cannot be modified later. Change-Id: Id41b1a157e3ec1ca30f26b0e37c20d59d7fb983e Signed-off-by: Robert Varga --- .../plaintext/localfile/PlaintextLocalFileStorage.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/keystore/plaintext-localfile/src/main/java/org/opendaylight/netconf/keystore/plaintext/localfile/PlaintextLocalFileStorage.java b/keystore/plaintext-localfile/src/main/java/org/opendaylight/netconf/keystore/plaintext/localfile/PlaintextLocalFileStorage.java index add96d2037..25f88554af 100644 --- a/keystore/plaintext-localfile/src/main/java/org/opendaylight/netconf/keystore/plaintext/localfile/PlaintextLocalFileStorage.java +++ b/keystore/plaintext-localfile/src/main/java/org/opendaylight/netconf/keystore/plaintext/localfile/PlaintextLocalFileStorage.java @@ -141,7 +141,7 @@ public class PlaintextLocalFileStorage implements MutablePlaintextStorage { return existing.publicValue(); } final var entries = new HashSet<>(entries()); - entries.add(new StorageEntry(key, value)); + entries.add(new StorageEntry(key.clone(), value.clone())); updateWith(Set.copyOf(entries)); return null; } @@ -157,7 +157,7 @@ public class PlaintextLocalFileStorage implements MutablePlaintextStorage { } entries.remove(previous); } - entries.add(new StorageEntry(key, value)); + entries.add(new StorageEntry(key.clone(), value.clone())); updateWith(Set.copyOf(entries)); return previous == null ? null : previous.publicValue(); } -- 2.36.6