This is an automated email from the ASF dual-hosted git repository. rgoers pushed a commit to branch release-2.x in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
commit 18560afaef4300df93b0ff8c85f5acbb932e9573 Author: Mattia Bertorello <[email protected]> AuthorDate: Thu Jul 4 12:31:48 2019 +0200 Return always six bytes also when there is an ipv4 or ipv6 The localhost address is used for emulate a mac address when is not available --- .../src/main/java/org/apache/logging/log4j/core/util/NetUtils.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/NetUtils.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/NetUtils.java index f3fbff8..e848822 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/NetUtils.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/NetUtils.java @@ -25,6 +25,7 @@ import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.net.UnknownHostException; +import java.util.Arrays; import java.util.Enumeration; import org.apache.logging.log4j.Logger; @@ -105,7 +106,10 @@ public final class NetUtils { LOGGER.catching(e); } if (mac == null || mac.length == 0) { - mac = localHost.getAddress(); + // Emulate a mac address with an IP v4 or v6 + final byte[] address = localHost.getAddress(); + // Take only 6 bytes if the address is an IPv6 otherwise will pad with two zero bytes + mac = Arrays.copyOf(address, 6); } } catch (final UnknownHostException ignored) { // ignored
