From 0d5108de1d180f2fff4c3110c110661e11ae5e71 Mon Sep 17 00:00:00 2001 From: zzz <zzz@i2pmail.org> Date: Sat, 22 Mar 2025 14:48:01 -0400 Subject: [PATCH] Router: Prevent double-free of SHA256 instances from Noise --- history.txt | 12 ++++++++++++ .../southernstorm/noise/protocol/SymmetricState.java | 9 ++++++++- router/java/src/net/i2p/router/RouterVersion.java | 4 ++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/history.txt b/history.txt index feda3e8330..43f1f4fe22 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,15 @@ +2025-03-22 zzz + * Router: Prevent double-free of SHA256 instances from Noise + +2025-03-21 zzz + * Build: Add cs man pages, cs, pt_BR, zh_TW eepsite help pages + +2025-03-19 zzz + * Build: Remove more files from Debian source tarball + * Console: Reduce memory usage in BanlistRenderer + * i2psnark: Use torrent name instead of torrent file name in notifications + * i2ptunnel: Version the proxy CSS in more places + 2025-03-17 2.8.1 (API 0.9.65) released 2025-03-14 zzz diff --git a/router/java/src/com/southernstorm/noise/protocol/SymmetricState.java b/router/java/src/com/southernstorm/noise/protocol/SymmetricState.java index 218f65a538..68f641e899 100644 --- a/router/java/src/com/southernstorm/noise/protocol/SymmetricState.java +++ b/router/java/src/com/southernstorm/noise/protocol/SymmetricState.java @@ -101,6 +101,7 @@ class SymmetricState implements Destroyable, Cloneable { private final byte[] ck; private final byte[] h; private final byte[] prev_h; + private boolean isDestroyed; /** * Constructs a new symmetric state object. @@ -402,7 +403,13 @@ class SymmetricState implements Destroyable, Cloneable { } @Override - public void destroy() { + public synchronized void destroy() { + if (isDestroyed) { + // prevent double-free of hash + //(new Exception("Already destroyed")).printStackTrace(); + return; + } + isDestroyed = true; cipher.destroy(); hash.reset(); Noise.releaseHash(hash); diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 1984cf18c3..3b3b7dfadf 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -19,8 +19,8 @@ public class RouterVersion { public final static String ID = "Git"; public final static String VERSION = CoreVersion.VERSION; /** for example: "beta", "alpha", "rc" */ - public final static String QUALIFIER = ""; - public final static long BUILD = 0; + public final static String QUALIFIER = "-rc"; + public final static long BUILD = 1; /** for example "-test" */ public final static String EXTRA = ""; public final static String FULL_VERSION = VERSION + "-" + BUILD + QUALIFIER + EXTRA; -- GitLab