[jira] [Commented] (LOG4J2-2650) ArrayIndexOutOfBoundsException in the initialization of UuidUtil

2020-12-21 Thread Michel Graciano (Jira)


[ 
https://issues.apache.org/jira/browse/LOG4J2-2650?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17252852#comment-17252852
 ] 

Michel Graciano commented on LOG4J2-2650:
-

[~andreas12] there was another fix in LOG4J2-2707. Please take a look at 2.13.0 
or newer versions.

> ArrayIndexOutOfBoundsException in the initialization of UuidUtil
> 
>
> Key: LOG4J2-2650
> URL: https://issues.apache.org/jira/browse/LOG4J2-2650
> Project: Log4j 2
>  Issue Type: Bug
>  Components: Core
>Affects Versions: 2.12.0
> Environment: os : Mac OS
> java: 1.8 (jdk1.8.0_172.jdk)
> none network interfaces connected
>Reporter: Mattia Bertorello
>Priority: Major
> Fix For: 2.12.1
>
>  Time Spent: 1h
>  Remaining Estimate: 0h
>
> Hi, 
> I found a problem in the UuidUtil initialization.
> The code that generate the exception
> {code:java}
>   private static Logger log = LogManager.getLogger(MyClass.class);
> {code}
> This code return a ip address of localhost and when the stack is IPv4 return 
> 4 bytes but when the default stack is IPv6 it's going to return 16 bytes.
>   
> [NetUtils.java#L108|https://github.com/apache/logging-log4j2/blob/da539329d528d979f4dd385a6ebb639793ef37bd/log4j-core/src/main/java/org/apache/logging/log4j/core/util/NetUtils.java#L108]
> {code:java}
> if (mac == null || mac.length == 0) { 
>mac = localHost.getAddress(); 
> }
> {code}
> This is the part that generate the ArrayIndexOutOfBoundsException
>  
> [UuidUtil.java#L81|https://github.com/apache/logging-log4j2/blob/da539329d528d979f4dd385a6ebb639793ef37bd/log4j-core/src/main/java/org/apache/logging/log4j/core/util/UuidUtil.java#L81]
> {code:java}
> System.arraycopy(mac, index, node, index + 2, length);{code}
> These 16 bytes will generate a wrong destination index that exceed the length 
> of the node array.
> {noformat}
> mac = {byte[16]@3217} 
> length = 6 
> index = 10 
> node = {byte[8]@3222}
> {noformat}
> This is the complete exception  
> {code}
> java.lang.ExceptionInInitializerError at 
> org.apache.logging.log4j.core.util.WatchManager.(WatchManager.java:53) 
> at 
> org.apache.logging.log4j.core.config.AbstractConfiguration.(AbstractConfiguration.java:135)
>  at 
> org.apache.logging.log4j.core.config.NullConfiguration.(NullConfiguration.java:32)
>  at 
> org.apache.logging.log4j.core.LoggerContext.(LoggerContext.java:79) 
> at 
> org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.createContext(ClassLoaderContextSelector.java:171)
>  at 
> org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:145)
>  at 
> org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:70)
>  at 
> org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:57)
>  at 
> org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:148)
>  at 
> org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
>  at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194) at 
> org.apache.logging.log4j.LogManager.getLogger(LogManager.java:581) at 
> cc.arduino.contributions.packages.ContributionInstaller.(ContributionInstaller.java:66)
>  at processing.app.Base.(Base.java:291) at 
> processing.app.Base.main(Base.java:150) Caused by: 
> java.lang.ArrayIndexOutOfBoundsException at java.lang.System.arraycopy(Native 
> Method) at 
> org.apache.logging.log4j.core.util.UuidUtil.(UuidUtil.java:81) ... 15 
> more
> {code}
> To reproduce the exception you need
>  * disconnect every network interface
>  * verify that java will use the IPv6 stack -Djava.net.preferIPv4Stack=false 
> -Djava.net.preferIPv6Addresses=true
>  * Initialize a log of log4j
> I suggest different solution:
>  - Remove  
> [NetUtils.java#L108|https://github.com/apache/logging-log4j2/blob/da539329d528d979f4dd385a6ebb639793ef37bd/log4j-core/src/main/java/org/apache/logging/log4j/core/util/NetUtils.java#L108]
>  and return always null (when the other code fail to init the mac variable ) 
> because in general the method is called getMacAddress but in that particular 
> case will return and IP address 
>  - Mange the IPv6 case in the static part of the class UuidUtil 
> [UuidUtil.java#L81|https://github.com/apache/logging-log4j2/blob/da539329d528d979f4dd385a6ebb639793ef37bd/log4j-core/src/main/java/org/apache/logging/log4j/core/util/UuidUtil.java#L81]



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (LOG4J2-2650) ArrayIndexOutOfBoundsException in the initialization of UuidUtil

2020-09-04 Thread Andreas Glauner (Jira)


[ 
https://issues.apache.org/jira/browse/LOG4J2-2650?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17190805#comment-17190805
 ] 

Andreas Glauner commented on LOG4J2-2650:
-

Sorry for the blunt question: Has this really been fixed with 2.12.1? We are 
getting the same error with that version.

> ArrayIndexOutOfBoundsException in the initialization of UuidUtil
> 
>
> Key: LOG4J2-2650
> URL: https://issues.apache.org/jira/browse/LOG4J2-2650
> Project: Log4j 2
>  Issue Type: Bug
>  Components: Core
>Affects Versions: 2.12.0
> Environment: os : Mac OS
> java: 1.8 (jdk1.8.0_172.jdk)
> none network interfaces connected
>Reporter: Mattia Bertorello
>Priority: Major
> Fix For: 2.12.1
>
>  Time Spent: 1h
>  Remaining Estimate: 0h
>
> Hi, 
> I found a problem in the UuidUtil initialization.
> The code that generate the exception
> {code:java}
>   private static Logger log = LogManager.getLogger(MyClass.class);
> {code}
> This code return a ip address of localhost and when the stack is IPv4 return 
> 4 bytes but when the default stack is IPv6 it's going to return 16 bytes.
>   
> [NetUtils.java#L108|https://github.com/apache/logging-log4j2/blob/da539329d528d979f4dd385a6ebb639793ef37bd/log4j-core/src/main/java/org/apache/logging/log4j/core/util/NetUtils.java#L108]
> {code:java}
> if (mac == null || mac.length == 0) { 
>mac = localHost.getAddress(); 
> }
> {code}
> This is the part that generate the ArrayIndexOutOfBoundsException
>  
> [UuidUtil.java#L81|https://github.com/apache/logging-log4j2/blob/da539329d528d979f4dd385a6ebb639793ef37bd/log4j-core/src/main/java/org/apache/logging/log4j/core/util/UuidUtil.java#L81]
> {code:java}
> System.arraycopy(mac, index, node, index + 2, length);{code}
> These 16 bytes will generate a wrong destination index that exceed the length 
> of the node array.
> {noformat}
> mac = {byte[16]@3217} 
> length = 6 
> index = 10 
> node = {byte[8]@3222}
> {noformat}
> This is the complete exception  
> {code}
> java.lang.ExceptionInInitializerError at 
> org.apache.logging.log4j.core.util.WatchManager.(WatchManager.java:53) 
> at 
> org.apache.logging.log4j.core.config.AbstractConfiguration.(AbstractConfiguration.java:135)
>  at 
> org.apache.logging.log4j.core.config.NullConfiguration.(NullConfiguration.java:32)
>  at 
> org.apache.logging.log4j.core.LoggerContext.(LoggerContext.java:79) 
> at 
> org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.createContext(ClassLoaderContextSelector.java:171)
>  at 
> org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:145)
>  at 
> org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:70)
>  at 
> org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:57)
>  at 
> org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:148)
>  at 
> org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
>  at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194) at 
> org.apache.logging.log4j.LogManager.getLogger(LogManager.java:581) at 
> cc.arduino.contributions.packages.ContributionInstaller.(ContributionInstaller.java:66)
>  at processing.app.Base.(Base.java:291) at 
> processing.app.Base.main(Base.java:150) Caused by: 
> java.lang.ArrayIndexOutOfBoundsException at java.lang.System.arraycopy(Native 
> Method) at 
> org.apache.logging.log4j.core.util.UuidUtil.(UuidUtil.java:81) ... 15 
> more
> {code}
> To reproduce the exception you need
>  * disconnect every network interface
>  * verify that java will use the IPv6 stack -Djava.net.preferIPv4Stack=false 
> -Djava.net.preferIPv6Addresses=true
>  * Initialize a log of log4j
> I suggest different solution:
>  - Remove  
> [NetUtils.java#L108|https://github.com/apache/logging-log4j2/blob/da539329d528d979f4dd385a6ebb639793ef37bd/log4j-core/src/main/java/org/apache/logging/log4j/core/util/NetUtils.java#L108]
>  and return always null (when the other code fail to init the mac variable ) 
> because in general the method is called getMacAddress but in that particular 
> case will return and IP address 
>  - Mange the IPv6 case in the static part of the class UuidUtil 
> [UuidUtil.java#L81|https://github.com/apache/logging-log4j2/blob/da539329d528d979f4dd385a6ebb639793ef37bd/log4j-core/src/main/java/org/apache/logging/log4j/core/util/UuidUtil.java#L81]



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (LOG4J2-2650) ArrayIndexOutOfBoundsException in the initialization of UuidUtil

2019-07-28 Thread ASF subversion and git services (JIRA)


[ 
https://issues.apache.org/jira/browse/LOG4J2-2650?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16894878#comment-16894878
 ] 

ASF subversion and git services commented on LOG4J2-2650:
-

Commit 6d02d668a306872d7cc6d1d0bd01bab3c8413ea6 in logging-log4j2's branch 
refs/heads/release-2.x from Ralph Goers
[ https://gitbox.apache.org/repos/asf?p=logging-log4j2.git;h=6d02d66 ]

LOG4J2-2650 - Support emulating a MAC address when using ipv6


> ArrayIndexOutOfBoundsException in the initialization of UuidUtil
> 
>
> Key: LOG4J2-2650
> URL: https://issues.apache.org/jira/browse/LOG4J2-2650
> Project: Log4j 2
>  Issue Type: Bug
>  Components: Core
>Affects Versions: 2.12.0
> Environment: os : Mac OS
> java: 1.8 (jdk1.8.0_172.jdk)
> none network interfaces connected
>Reporter: Mattia Bertorello
>Priority: Major
>  Time Spent: 1h
>  Remaining Estimate: 0h
>
> Hi, 
> I found a problem in the UuidUtil initialization.
> The code that generate the exception
> {code:java}
>   private static Logger log = LogManager.getLogger(MyClass.class);
> {code}
> This code return a ip address of localhost and when the stack is IPv4 return 
> 4 bytes but when the default stack is IPv6 it's going to return 16 bytes.
>   
> [NetUtils.java#L108|https://github.com/apache/logging-log4j2/blob/da539329d528d979f4dd385a6ebb639793ef37bd/log4j-core/src/main/java/org/apache/logging/log4j/core/util/NetUtils.java#L108]
> {code:java}
> if (mac == null || mac.length == 0) { 
>mac = localHost.getAddress(); 
> }
> {code}
> This is the part that generate the ArrayIndexOutOfBoundsException
>  
> [UuidUtil.java#L81|https://github.com/apache/logging-log4j2/blob/da539329d528d979f4dd385a6ebb639793ef37bd/log4j-core/src/main/java/org/apache/logging/log4j/core/util/UuidUtil.java#L81]
> {code:java}
> System.arraycopy(mac, index, node, index + 2, length);{code}
> These 16 bytes will generate a wrong destination index that exceed the length 
> of the node array.
> {noformat}
> mac = {byte[16]@3217} 
> length = 6 
> index = 10 
> node = {byte[8]@3222}
> {noformat}
> This is the complete exception  
> {code}
> java.lang.ExceptionInInitializerError at 
> org.apache.logging.log4j.core.util.WatchManager.(WatchManager.java:53) 
> at 
> org.apache.logging.log4j.core.config.AbstractConfiguration.(AbstractConfiguration.java:135)
>  at 
> org.apache.logging.log4j.core.config.NullConfiguration.(NullConfiguration.java:32)
>  at 
> org.apache.logging.log4j.core.LoggerContext.(LoggerContext.java:79) 
> at 
> org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.createContext(ClassLoaderContextSelector.java:171)
>  at 
> org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:145)
>  at 
> org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:70)
>  at 
> org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:57)
>  at 
> org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:148)
>  at 
> org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
>  at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194) at 
> org.apache.logging.log4j.LogManager.getLogger(LogManager.java:581) at 
> cc.arduino.contributions.packages.ContributionInstaller.(ContributionInstaller.java:66)
>  at processing.app.Base.(Base.java:291) at 
> processing.app.Base.main(Base.java:150) Caused by: 
> java.lang.ArrayIndexOutOfBoundsException at java.lang.System.arraycopy(Native 
> Method) at 
> org.apache.logging.log4j.core.util.UuidUtil.(UuidUtil.java:81) ... 15 
> more
> {code}
> To reproduce the exception you need
>  * disconnect every network interface
>  * verify that java will use the IPv6 stack -Djava.net.preferIPv4Stack=false 
> -Djava.net.preferIPv6Addresses=true
>  * Initialize a log of log4j
> I suggest different solution:
>  - Remove  
> [NetUtils.java#L108|https://github.com/apache/logging-log4j2/blob/da539329d528d979f4dd385a6ebb639793ef37bd/log4j-core/src/main/java/org/apache/logging/log4j/core/util/NetUtils.java#L108]
>  and return always null (when the other code fail to init the mac variable ) 
> because in general the method is called getMacAddress but in that particular 
> case will return and IP address 
>  - Mange the IPv6 case in the static part of the class UuidUtil 
> [UuidUtil.java#L81|https://github.com/apache/logging-log4j2/blob/da539329d528d979f4dd385a6ebb639793ef37bd/log4j-core/src/main/java/org/apache/logging/log4j/core/util/UuidUtil.java#L81]



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)


[jira] [Commented] (LOG4J2-2650) ArrayIndexOutOfBoundsException in the initialization of UuidUtil

2019-07-28 Thread ASF subversion and git services (JIRA)


[ 
https://issues.apache.org/jira/browse/LOG4J2-2650?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16894877#comment-16894877
 ] 

ASF subversion and git services commented on LOG4J2-2650:
-

Commit e50c485380f23fb4c84173757c1808952b257d8b in logging-log4j2's branch 
refs/heads/master from Ralph Goers
[ https://gitbox.apache.org/repos/asf?p=logging-log4j2.git;h=e50c485 ]

LOG4J2-2650 - Support emulating a MAC address when using ipv6


> ArrayIndexOutOfBoundsException in the initialization of UuidUtil
> 
>
> Key: LOG4J2-2650
> URL: https://issues.apache.org/jira/browse/LOG4J2-2650
> Project: Log4j 2
>  Issue Type: Bug
>  Components: Core
>Affects Versions: 2.12.0
> Environment: os : Mac OS
> java: 1.8 (jdk1.8.0_172.jdk)
> none network interfaces connected
>Reporter: Mattia Bertorello
>Priority: Major
>  Time Spent: 1h
>  Remaining Estimate: 0h
>
> Hi, 
> I found a problem in the UuidUtil initialization.
> The code that generate the exception
> {code:java}
>   private static Logger log = LogManager.getLogger(MyClass.class);
> {code}
> This code return a ip address of localhost and when the stack is IPv4 return 
> 4 bytes but when the default stack is IPv6 it's going to return 16 bytes.
>   
> [NetUtils.java#L108|https://github.com/apache/logging-log4j2/blob/da539329d528d979f4dd385a6ebb639793ef37bd/log4j-core/src/main/java/org/apache/logging/log4j/core/util/NetUtils.java#L108]
> {code:java}
> if (mac == null || mac.length == 0) { 
>mac = localHost.getAddress(); 
> }
> {code}
> This is the part that generate the ArrayIndexOutOfBoundsException
>  
> [UuidUtil.java#L81|https://github.com/apache/logging-log4j2/blob/da539329d528d979f4dd385a6ebb639793ef37bd/log4j-core/src/main/java/org/apache/logging/log4j/core/util/UuidUtil.java#L81]
> {code:java}
> System.arraycopy(mac, index, node, index + 2, length);{code}
> These 16 bytes will generate a wrong destination index that exceed the length 
> of the node array.
> {noformat}
> mac = {byte[16]@3217} 
> length = 6 
> index = 10 
> node = {byte[8]@3222}
> {noformat}
> This is the complete exception  
> {code}
> java.lang.ExceptionInInitializerError at 
> org.apache.logging.log4j.core.util.WatchManager.(WatchManager.java:53) 
> at 
> org.apache.logging.log4j.core.config.AbstractConfiguration.(AbstractConfiguration.java:135)
>  at 
> org.apache.logging.log4j.core.config.NullConfiguration.(NullConfiguration.java:32)
>  at 
> org.apache.logging.log4j.core.LoggerContext.(LoggerContext.java:79) 
> at 
> org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.createContext(ClassLoaderContextSelector.java:171)
>  at 
> org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:145)
>  at 
> org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:70)
>  at 
> org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:57)
>  at 
> org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:148)
>  at 
> org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
>  at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194) at 
> org.apache.logging.log4j.LogManager.getLogger(LogManager.java:581) at 
> cc.arduino.contributions.packages.ContributionInstaller.(ContributionInstaller.java:66)
>  at processing.app.Base.(Base.java:291) at 
> processing.app.Base.main(Base.java:150) Caused by: 
> java.lang.ArrayIndexOutOfBoundsException at java.lang.System.arraycopy(Native 
> Method) at 
> org.apache.logging.log4j.core.util.UuidUtil.(UuidUtil.java:81) ... 15 
> more
> {code}
> To reproduce the exception you need
>  * disconnect every network interface
>  * verify that java will use the IPv6 stack -Djava.net.preferIPv4Stack=false 
> -Djava.net.preferIPv6Addresses=true
>  * Initialize a log of log4j
> I suggest different solution:
>  - Remove  
> [NetUtils.java#L108|https://github.com/apache/logging-log4j2/blob/da539329d528d979f4dd385a6ebb639793ef37bd/log4j-core/src/main/java/org/apache/logging/log4j/core/util/NetUtils.java#L108]
>  and return always null (when the other code fail to init the mac variable ) 
> because in general the method is called getMacAddress but in that particular 
> case will return and IP address 
>  - Mange the IPv6 case in the static part of the class UuidUtil 
> [UuidUtil.java#L81|https://github.com/apache/logging-log4j2/blob/da539329d528d979f4dd385a6ebb639793ef37bd/log4j-core/src/main/java/org/apache/logging/log4j/core/util/UuidUtil.java#L81]



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)


[jira] [Commented] (LOG4J2-2650) ArrayIndexOutOfBoundsException in the initialization of UuidUtil

2019-07-28 Thread ASF subversion and git services (JIRA)


[ 
https://issues.apache.org/jira/browse/LOG4J2-2650?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16894866#comment-16894866
 ] 

ASF subversion and git services commented on LOG4J2-2650:
-

Commit 4cc4482cc9bc83e68caa991bf7f65c881ef5969b in logging-log4j2's branch 
refs/heads/master from Ralph Goers
[ https://gitbox.apache.org/repos/asf?p=logging-log4j2.git;h=4cc4482 ]

Merge pull request #290 from mattiabertorello/LOG4J2-2650

[LOG4J2-2650] Fix ArrayIndexOutOfBoundsException when the mac variable is an 
ipv6

> ArrayIndexOutOfBoundsException in the initialization of UuidUtil
> 
>
> Key: LOG4J2-2650
> URL: https://issues.apache.org/jira/browse/LOG4J2-2650
> Project: Log4j 2
>  Issue Type: Bug
>  Components: Core
>Affects Versions: 2.12.0
> Environment: os : Mac OS
> java: 1.8 (jdk1.8.0_172.jdk)
> none network interfaces connected
>Reporter: Mattia Bertorello
>Priority: Major
>  Time Spent: 1h
>  Remaining Estimate: 0h
>
> Hi, 
> I found a problem in the UuidUtil initialization.
> The code that generate the exception
> {code:java}
>   private static Logger log = LogManager.getLogger(MyClass.class);
> {code}
> This code return a ip address of localhost and when the stack is IPv4 return 
> 4 bytes but when the default stack is IPv6 it's going to return 16 bytes.
>   
> [NetUtils.java#L108|https://github.com/apache/logging-log4j2/blob/da539329d528d979f4dd385a6ebb639793ef37bd/log4j-core/src/main/java/org/apache/logging/log4j/core/util/NetUtils.java#L108]
> {code:java}
> if (mac == null || mac.length == 0) { 
>mac = localHost.getAddress(); 
> }
> {code}
> This is the part that generate the ArrayIndexOutOfBoundsException
>  
> [UuidUtil.java#L81|https://github.com/apache/logging-log4j2/blob/da539329d528d979f4dd385a6ebb639793ef37bd/log4j-core/src/main/java/org/apache/logging/log4j/core/util/UuidUtil.java#L81]
> {code:java}
> System.arraycopy(mac, index, node, index + 2, length);{code}
> These 16 bytes will generate a wrong destination index that exceed the length 
> of the node array.
> {noformat}
> mac = {byte[16]@3217} 
> length = 6 
> index = 10 
> node = {byte[8]@3222}
> {noformat}
> This is the complete exception  
> {code}
> java.lang.ExceptionInInitializerError at 
> org.apache.logging.log4j.core.util.WatchManager.(WatchManager.java:53) 
> at 
> org.apache.logging.log4j.core.config.AbstractConfiguration.(AbstractConfiguration.java:135)
>  at 
> org.apache.logging.log4j.core.config.NullConfiguration.(NullConfiguration.java:32)
>  at 
> org.apache.logging.log4j.core.LoggerContext.(LoggerContext.java:79) 
> at 
> org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.createContext(ClassLoaderContextSelector.java:171)
>  at 
> org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:145)
>  at 
> org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:70)
>  at 
> org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:57)
>  at 
> org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:148)
>  at 
> org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
>  at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194) at 
> org.apache.logging.log4j.LogManager.getLogger(LogManager.java:581) at 
> cc.arduino.contributions.packages.ContributionInstaller.(ContributionInstaller.java:66)
>  at processing.app.Base.(Base.java:291) at 
> processing.app.Base.main(Base.java:150) Caused by: 
> java.lang.ArrayIndexOutOfBoundsException at java.lang.System.arraycopy(Native 
> Method) at 
> org.apache.logging.log4j.core.util.UuidUtil.(UuidUtil.java:81) ... 15 
> more
> {code}
> To reproduce the exception you need
>  * disconnect every network interface
>  * verify that java will use the IPv6 stack -Djava.net.preferIPv4Stack=false 
> -Djava.net.preferIPv6Addresses=true
>  * Initialize a log of log4j
> I suggest different solution:
>  - Remove  
> [NetUtils.java#L108|https://github.com/apache/logging-log4j2/blob/da539329d528d979f4dd385a6ebb639793ef37bd/log4j-core/src/main/java/org/apache/logging/log4j/core/util/NetUtils.java#L108]
>  and return always null (when the other code fail to init the mac variable ) 
> because in general the method is called getMacAddress but in that particular 
> case will return and IP address 
>  - Mange the IPv6 case in the static part of the class UuidUtil 
> [UuidUtil.java#L81|https://github.com/apache/logging-log4j2/blob/da539329d528d979f4dd385a6ebb639793ef37bd/log4j-core/src/main/java/org/apache/logging/log4j/core/util/UuidUtil.java#L81]



--
This message was sent by Atlassian JIRA

[jira] [Commented] (LOG4J2-2650) ArrayIndexOutOfBoundsException in the initialization of UuidUtil

2019-07-04 Thread Mattia Bertorello (JIRA)


[ 
https://issues.apache.org/jira/browse/LOG4J2-2650?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16878536#comment-16878536
 ] 

Mattia Bertorello commented on LOG4J2-2650:
---

Done [https://github.com/apache/logging-log4j2/pull/290] :) 

> ArrayIndexOutOfBoundsException in the initialization of UuidUtil
> 
>
> Key: LOG4J2-2650
> URL: https://issues.apache.org/jira/browse/LOG4J2-2650
> Project: Log4j 2
>  Issue Type: Bug
>  Components: Core
>Affects Versions: 2.12.0
> Environment: os : Mac OS
> java: 1.8 (jdk1.8.0_172.jdk)
> none network interfaces connected
>Reporter: Mattia Bertorello
>Priority: Major
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> Hi, 
> I found a problem in the UuidUtil initialization.
> The code that generate the exception
> {code:java}
>   private static Logger log = LogManager.getLogger(MyClass.class);
> {code}
> This code return a ip address of localhost and when the stack is IPv4 return 
> 4 bytes but when the default stack is IPv6 it's going to return 16 bytes.
>   
> [NetUtils.java#L108|https://github.com/apache/logging-log4j2/blob/da539329d528d979f4dd385a6ebb639793ef37bd/log4j-core/src/main/java/org/apache/logging/log4j/core/util/NetUtils.java#L108]
> {code:java}
> if (mac == null || mac.length == 0) { 
>mac = localHost.getAddress(); 
> }
> {code}
> This is the part that generate the ArrayIndexOutOfBoundsException
>  
> [UuidUtil.java#L81|https://github.com/apache/logging-log4j2/blob/da539329d528d979f4dd385a6ebb639793ef37bd/log4j-core/src/main/java/org/apache/logging/log4j/core/util/UuidUtil.java#L81]
> {code:java}
> System.arraycopy(mac, index, node, index + 2, length);{code}
> These 16 bytes will generate a wrong destination index that exceed the length 
> of the node array.
> {noformat}
> mac = {byte[16]@3217} 
> length = 6 
> index = 10 
> node = {byte[8]@3222}
> {noformat}
> This is the complete exception  
> {code}
> java.lang.ExceptionInInitializerError at 
> org.apache.logging.log4j.core.util.WatchManager.(WatchManager.java:53) 
> at 
> org.apache.logging.log4j.core.config.AbstractConfiguration.(AbstractConfiguration.java:135)
>  at 
> org.apache.logging.log4j.core.config.NullConfiguration.(NullConfiguration.java:32)
>  at 
> org.apache.logging.log4j.core.LoggerContext.(LoggerContext.java:79) 
> at 
> org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.createContext(ClassLoaderContextSelector.java:171)
>  at 
> org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:145)
>  at 
> org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:70)
>  at 
> org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:57)
>  at 
> org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:148)
>  at 
> org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
>  at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194) at 
> org.apache.logging.log4j.LogManager.getLogger(LogManager.java:581) at 
> cc.arduino.contributions.packages.ContributionInstaller.(ContributionInstaller.java:66)
>  at processing.app.Base.(Base.java:291) at 
> processing.app.Base.main(Base.java:150) Caused by: 
> java.lang.ArrayIndexOutOfBoundsException at java.lang.System.arraycopy(Native 
> Method) at 
> org.apache.logging.log4j.core.util.UuidUtil.(UuidUtil.java:81) ... 15 
> more
> {code}
> To reproduce the exception you need
>  * disconnect every network interface
>  * verify that java will use the IPv6 stack -Djava.net.preferIPv4Stack=false 
> -Djava.net.preferIPv6Addresses=true
>  * Initialize a log of log4j
> I suggest different solution:
>  - Remove  
> [NetUtils.java#L108|https://github.com/apache/logging-log4j2/blob/da539329d528d979f4dd385a6ebb639793ef37bd/log4j-core/src/main/java/org/apache/logging/log4j/core/util/NetUtils.java#L108]
>  and return always null (when the other code fail to init the mac variable ) 
> because in general the method is called getMacAddress but in that particular 
> case will return and IP address 
>  - Mange the IPv6 case in the static part of the class UuidUtil 
> [UuidUtil.java#L81|https://github.com/apache/logging-log4j2/blob/da539329d528d979f4dd385a6ebb639793ef37bd/log4j-core/src/main/java/org/apache/logging/log4j/core/util/UuidUtil.java#L81]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (LOG4J2-2650) ArrayIndexOutOfBoundsException in the initialization of UuidUtil

2019-07-02 Thread Gary Gregory (JIRA)


[ 
https://issues.apache.org/jira/browse/LOG4J2-2650?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16877046#comment-16877046
 ] 

Gary Gregory commented on LOG4J2-2650:
--

[~mattiab],

Feel free to provide a patch on GitHub ;)

 

> ArrayIndexOutOfBoundsException in the initialization of UuidUtil
> 
>
> Key: LOG4J2-2650
> URL: https://issues.apache.org/jira/browse/LOG4J2-2650
> Project: Log4j 2
>  Issue Type: Bug
>  Components: Core
>Affects Versions: 2.12.0
> Environment: os : Mac OS
> java: 1.8 (jdk1.8.0_172.jdk)
> none network interfaces connected
>Reporter: Mattia Bertorello
>Priority: Major
>
> Hi, 
> I found a problem in the UuidUtil initialization.
> The code that generate the exception
> {code:java}
>   private static Logger log = LogManager.getLogger(MyClass.class);
> {code}
> This code return a ip address of localhost and when the stack is IPv4 return 
> 4 bytes but when the default stack is IPv6 it's going to return 16 bytes.
>   
> [NetUtils.java#L108|https://github.com/apache/logging-log4j2/blob/da539329d528d979f4dd385a6ebb639793ef37bd/log4j-core/src/main/java/org/apache/logging/log4j/core/util/NetUtils.java#L108]
> {code:java}
> if (mac == null || mac.length == 0) { 
>mac = localHost.getAddress(); 
> }
> {code}
> This is the part that generate the ArrayIndexOutOfBoundsException
>  
> [UuidUtil.java#L81|https://github.com/apache/logging-log4j2/blob/da539329d528d979f4dd385a6ebb639793ef37bd/log4j-core/src/main/java/org/apache/logging/log4j/core/util/UuidUtil.java#L81]
> {code:java}
> System.arraycopy(mac, index, node, index + 2, length);{code}
> These 16 bytes will generate a wrong destination index that exceed the length 
> of the node array.
> {noformat}
> mac = {byte[16]@3217} 
> length = 6 
> index = 10 
> node = {byte[8]@3222}
> {noformat}
> This is the complete exception  
> {code}
> java.lang.ExceptionInInitializerError at 
> org.apache.logging.log4j.core.util.WatchManager.(WatchManager.java:53) 
> at 
> org.apache.logging.log4j.core.config.AbstractConfiguration.(AbstractConfiguration.java:135)
>  at 
> org.apache.logging.log4j.core.config.NullConfiguration.(NullConfiguration.java:32)
>  at 
> org.apache.logging.log4j.core.LoggerContext.(LoggerContext.java:79) 
> at 
> org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.createContext(ClassLoaderContextSelector.java:171)
>  at 
> org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.locateContext(ClassLoaderContextSelector.java:145)
>  at 
> org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:70)
>  at 
> org.apache.logging.log4j.core.selector.ClassLoaderContextSelector.getContext(ClassLoaderContextSelector.java:57)
>  at 
> org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:148)
>  at 
> org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
>  at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194) at 
> org.apache.logging.log4j.LogManager.getLogger(LogManager.java:581) at 
> cc.arduino.contributions.packages.ContributionInstaller.(ContributionInstaller.java:66)
>  at processing.app.Base.(Base.java:291) at 
> processing.app.Base.main(Base.java:150) Caused by: 
> java.lang.ArrayIndexOutOfBoundsException at java.lang.System.arraycopy(Native 
> Method) at 
> org.apache.logging.log4j.core.util.UuidUtil.(UuidUtil.java:81) ... 15 
> more
> {code}
> To reproduce the exception you need
>  * disconnect every network interface
>  * verify that java will use the IPv6 stack -Djava.net.preferIPv4Stack=false 
> -Djava.net.preferIPv6Addresses=true
>  * Initialize a log of log4j
> I suggest different solution:
>  - Remove  
> [NetUtils.java#L108|https://github.com/apache/logging-log4j2/blob/da539329d528d979f4dd385a6ebb639793ef37bd/log4j-core/src/main/java/org/apache/logging/log4j/core/util/NetUtils.java#L108]
>  and return always null (when the other code fail to init the mac variable ) 
> because in general the method is called getMacAddress but in that particular 
> case will return and IP address 
>  - Mange the IPv6 case in the static part of the class UuidUtil 
> [UuidUtil.java#L81|https://github.com/apache/logging-log4j2/blob/da539329d528d979f4dd385a6ebb639793ef37bd/log4j-core/src/main/java/org/apache/logging/log4j/core/util/UuidUtil.java#L81]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)