I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 8258cdd6 authored by zzz's avatar zzz
Browse files

Limit max header lines

parent 2fcee6e8
No related branches found
No related tags found
No related merge requests found
...@@ -321,6 +321,9 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer { ...@@ -321,6 +321,9 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
return buf.toString(); return buf.toString();
} }
/** ridiculously long, just to prevent OOM DOS @since 0.7.13 */
private static final int MAX_HEADERS = 60;
private Properties readHeaders(InputStream in, StringBuilder command) throws IOException { private Properties readHeaders(InputStream in, StringBuilder command) throws IOException {
Properties headers = new Properties(); Properties headers = new Properties();
StringBuilder buf = new StringBuilder(128); StringBuilder buf = new StringBuilder(128);
...@@ -344,7 +347,10 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer { ...@@ -344,7 +347,10 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
if (trimmed > 0) if (trimmed > 0)
getTunnel().getContext().statManager().addRateData("i2ptunnel.httpNullWorkaround", trimmed, 0); getTunnel().getContext().statManager().addRateData("i2ptunnel.httpNullWorkaround", trimmed, 0);
int i = 0;
while (true) { while (true) {
if (++i > MAX_HEADERS)
throw new IOException("Too many header lines - max " + MAX_HEADERS);
buf.setLength(0); buf.setLength(0);
ok = DataHelper.readLine(in, buf); ok = DataHelper.readLine(in, buf);
if (!ok) throw new IOException("EOF reached before the end of the headers [" + buf.toString() + "]"); if (!ok) throw new IOException("EOF reached before the end of the headers [" + buf.toString() + "]");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment