You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rg...@apache.org on 2019/07/29 02:12:15 UTC
[logging-log4j2] branch master updated: 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
This is an automated email from the ASF dual-hosted git repository.
rgoers pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
The following commit(s) were added to refs/heads/master by this push:
new 7a20796 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
new 4cc4482 Merge pull request #290 from mattiabertorello/LOG4J2-2650
7a20796 is described below
commit 7a207962cd019118a7c08db42abd38ab81e51deb
Author: Mattia Bertorello <m....@arduino.cc>
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