forked from I2P_Developers/i2p.i2p
SusiMail: Prevent infinite loop on decoding error
More test mods Fix StringBuilderWriter.write(int)
This commit is contained in:
@@ -85,10 +85,17 @@ public class DecodingOutputStream extends OutputStream {
|
|||||||
// So just check if we got a character back in the buffer.
|
// So just check if we got a character back in the buffer.
|
||||||
if (result == null || (result.isError() && !_cb.hasRemaining())) {
|
if (result == null || (result.isError() && !_cb.hasRemaining())) {
|
||||||
_out.write(REPLACEMENT);
|
_out.write(REPLACEMENT);
|
||||||
|
// need to do this or we will infinite loop
|
||||||
|
((Buffer)_bb).clear();
|
||||||
} else {
|
} else {
|
||||||
((Buffer)_cb).flip();
|
((Buffer)_cb).flip();
|
||||||
_out.append(_cb);
|
_out.append(_cb);
|
||||||
((Buffer)_cb).clear();
|
((Buffer)_cb).clear();
|
||||||
|
if (result.isError()) {
|
||||||
|
_out.write(REPLACEMENT);
|
||||||
|
// need to do this or we will infinite loop
|
||||||
|
((Buffer)_bb).clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,7 +114,7 @@ public class DecodingOutputStream extends OutputStream {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
try {
|
try {
|
||||||
String s = "Consider the encoding of the Euro sign, €." +
|
String s = "Consider the encoding of the Euro sign, €." +
|
||||||
" The Unicode code point for \"€\" is U+20AC.";
|
" The Unicode code point for \"€\" is U+20AC.\n";
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
for (int i = 0; i < 100; i++) {
|
for (int i = 0; i < 100; i++) {
|
||||||
buf.append(s);
|
buf.append(s);
|
||||||
@@ -118,10 +125,13 @@ public class DecodingOutputStream extends OutputStream {
|
|||||||
Writer w = new StringBuilderWriter();
|
Writer w = new StringBuilderWriter();
|
||||||
DecodingOutputStream r = new DecodingOutputStream(w, "UTF-8");
|
DecodingOutputStream r = new DecodingOutputStream(w, "UTF-8");
|
||||||
int b;
|
int b;
|
||||||
while ((b = bais.read()) >= 0) {
|
byte[] bf = new byte[256];
|
||||||
r.write(b);
|
int rand = 1 + net.i2p.I2PAppContext.getGlobalContext().random().nextInt(256);
|
||||||
|
while ((b = bais.read(bf, 0, rand)) >= 0) {
|
||||||
|
r.write(bf, 0, b);
|
||||||
|
rand = 1 + net.i2p.I2PAppContext.getGlobalContext().random().nextInt(256);
|
||||||
}
|
}
|
||||||
r.flush();
|
r.close();
|
||||||
System.out.println("Received: \"" + w.toString() + '"');
|
System.out.println("Received: \"" + w.toString() + '"');
|
||||||
System.out.println("Test passed? " + w.toString().equals(s));
|
System.out.println("Test passed? " + w.toString().equals(s));
|
||||||
bais = new java.io.ByteArrayInputStream(new byte[] { 'x', (byte) 0xcc, 'x' } );
|
bais = new java.io.ByteArrayInputStream(new byte[] { 'x', (byte) 0xcc, 'x' } );
|
||||||
@@ -130,7 +140,7 @@ public class DecodingOutputStream extends OutputStream {
|
|||||||
while ((b = bais.read()) >= 0) {
|
while ((b = bais.read()) >= 0) {
|
||||||
r.write(b);
|
r.write(b);
|
||||||
}
|
}
|
||||||
r.flush();
|
r.close();
|
||||||
System.out.println("Received: \"" + w.toString() + '"');
|
System.out.println("Received: \"" + w.toString() + '"');
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
ioe.printStackTrace();
|
ioe.printStackTrace();
|
||||||
|
@@ -47,7 +47,7 @@ public class StringBuilderWriter extends Writer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(int c) {
|
public void write(int c) {
|
||||||
buf.append(c);
|
buf.append((char) c);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -1,10 +1,13 @@
|
|||||||
2021-04-24 zzz
|
2021-04-24 zzz
|
||||||
* Jetty: Patch for CVE-2021-28165 Jetty #6072 -
|
* Jetty: Patch for CVE-2021-28165 Jetty #6072 -
|
||||||
Jetty server high CPU when client send data length > 17408
|
Jetty server high CPU when client send data length > 17408
|
||||||
|
* SusiMail: Fix infinite loop in decoder on malformed input
|
||||||
|
|
||||||
2021-04-24 zlatinb
|
2021-04-24 zlatinb
|
||||||
* SusiMail: Fix stream closed exception reading new mail
|
* SusiMail:
|
||||||
(trac ticket #2202, gitlab ticket #17)
|
- Fix stream closed exception reading new mail
|
||||||
|
(trac ticket #2202, gitlab ticket #17)
|
||||||
|
- Fix corruption of large messages (ticket #2765)
|
||||||
|
|
||||||
2021-04-23 idk
|
2021-04-23 idk
|
||||||
* Router: Fix update on Windows from very old versions (gitlab ticket #16)
|
* Router: Fix update on Windows from very old versions (gitlab ticket #16)
|
||||||
|
@@ -18,7 +18,7 @@ public class RouterVersion {
|
|||||||
/** deprecated */
|
/** deprecated */
|
||||||
public final static String ID = "Git";
|
public final static String ID = "Git";
|
||||||
public final static String VERSION = CoreVersion.VERSION;
|
public final static String VERSION = CoreVersion.VERSION;
|
||||||
public final static long BUILD = 14;
|
public final static long BUILD = 15;
|
||||||
|
|
||||||
/** for example "-test" */
|
/** for example "-test" */
|
||||||
public final static String EXTRA = "";
|
public final static String EXTRA = "";
|
||||||
|
Reference in New Issue
Block a user