Skip to content

Commit b4fdbe9

Browse files
committed
v2021.12.16 - several improvements
1 parent 73fd793 commit b4fdbe9

File tree

7 files changed

+248
-207
lines changed

7 files changed

+248
-207
lines changed

CHANGELOG.md

Whitespace-only changes.

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ exploded jar files just sitting uncompressed on the file-system (aka *.class).
1111

1212
# Example Usage:
1313

14-
java -jar log4j-detector-2021.12.15.jar [path-to-scan] > hits.txt
14+
java -jar log4j-detector-2021.12.16.jar [path-to-scan] > hits.txt
1515

1616
![Terminal output from running java -jar log4j-detector.jar in a terminal](./log4j-detector.png)
1717

1818
# More Example Usage:
1919

2020
```
21-
java -jar log4j-detector-2021.12.15.jar ./samples
21+
java -jar log4j-detector-2021.12.16.jar ./samples
2222
23-
-- github.com/mergebase/log4j-detector v2021.12.15 (by mergebase.com) analyzing paths (could take a while).
23+
-- github.com/mergebase/log4j-detector v2021.12.16 (by mergebase.com) analyzing paths (could take a while).
2424
-- Note: specify the '--verbose' flag to have every file examined printed to STDERR.
2525
/opt/mergebase/log4j-detector/samples/clt-1.0-SNAPSHOT.jar contains Log4J-2.x >= 2.10.0 _VULNERABLE_ :-(
2626
/opt/mergebase/log4j-detector/samples/infinispan-embedded-query-8.2.12.Final.jar contains Log4J-2.x >= 2.0-beta9 (< 2.10.0) _VULNERABLE_ :-(
@@ -84,15 +84,15 @@ your system (e.g., 1 GB or larger).
8484
# Usage
8585

8686
```
87-
java -jar log4j-detector-2021.12.15.jar
87+
java -jar log4j-detector-2021.12.16.jar
8888
89-
Usage: java -jar log4j-detector-2021.12.15.jar [--verbose] [paths to scan...]
89+
Usage: java -jar log4j-detector-2021.12.16.jar [--verbose] [paths to scan...]
9090
9191
Exit codes: 0 = No vulnerable Log4J versions found.
9292
1 = At least one legacy Log4J 1.x version found.
9393
2 = At least one vulnerable Log4J version found.
9494
95-
About - MergeBase log4j detector (version 2021.12.15)
95+
About - MergeBase log4j detector (version 2021.12.16)
9696
Docs - https://github.com/mergebase/log4j-detector
9797
(C) Copyright 2021 Mergebase Software Inc. Licensed to you via GPLv3.
9898
```
@@ -103,7 +103,7 @@ Docs - https://github.com/mergebase/log4j-detector
103103
git clone https://github.com/mergebase/log4j-detector.git
104104
cd log4j-detector/
105105
mvn install
106-
java -jar target/log4j-detector-2021.12.15.jar
106+
java -jar target/log4j-detector-2021.12.16.jar
107107
```
108108

109109
# License

log4j-detector-2021.12.16.jar

22.4 KB
Binary file not shown.

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>com.mergebase</groupId>
77
<artifactId>log4j-detector</artifactId>
8-
<version>2021.12.15</version>
8+
<version>2021.12.16</version>
99
<licenses>
1010
<license>
1111
<name>GPL-3.0-only</name>

src/main/java/com/mergebase/log4j/Bytes.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.mergebase.log4j;
22

3+
import java.io.ByteArrayInputStream;
34
import java.io.File;
45
import java.io.FileInputStream;
56
import java.io.IOException;
@@ -105,8 +106,21 @@ public static int[] fill(
105106
read += lastRead;
106107
}
107108
}
109+
110+
if (lastRead != -1 && read + offset == buf.length) {
111+
if (in.markSupported()) {
112+
in.mark(1);
113+
int peek = in.read();
114+
if (peek == -1) {
115+
lastRead = -1;
116+
} else {
117+
in.reset();
118+
}
119+
}
120+
}
121+
108122
// If read + offset == buf.length, we are done!
109-
return new int[]{offset + read, read + offset == buf.length ? -1 : lastRead};
123+
return new int[]{offset + read, lastRead};
110124
}
111125

112126
public static byte[] resizeArray(final byte[] bytes) {
@@ -161,4 +175,11 @@ private static int[] kmpFailure(byte[] pattern) {
161175
return failure;
162176
}
163177

178+
public static void disabledMain(String[] args) throws Exception {
179+
String abc = "abc";
180+
byte[] bytes = abc.getBytes(UTF_8);
181+
ByteArrayInputStream bin = new ByteArrayInputStream(bytes);
182+
byte[] result = Bytes.streamToBytes(bin, false, 2);
183+
System.out.println("AFTER = [" + new String(result, UTF_8) + "]");
184+
}
164185
}

0 commit comments

Comments
 (0)