mirror of https://github.com/zlatinb/muwire
limit the time a header read can take
parent
df71ade69f
commit
9373d58b53
|
@ -11,6 +11,7 @@ public class Constants {
|
|||
|
||||
public static final int MAX_HEADER_SIZE = 0x1 << 14;
|
||||
public static final int MAX_HEADERS = 16;
|
||||
public static final long MAX_HEADER_TIME = 60 * 1000;
|
||||
|
||||
public static final int MAX_RESULTS = 0x1 << 16;
|
||||
|
||||
|
|
|
@ -91,9 +91,12 @@ public class DataUtil {
|
|||
}
|
||||
|
||||
public static String readTillRN(InputStream is) throws IOException {
|
||||
final long start = System.currentTimeMillis();
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
while(baos.size() < (Constants.MAX_HEADER_SIZE)) {
|
||||
int read = is.read();
|
||||
if (System.currentTimeMillis() - start > Constants.MAX_HEADER_TIME)
|
||||
throw new IOException("header taking too long");
|
||||
if (read == -1)
|
||||
throw new IOException();
|
||||
if (read == '\r') {
|
||||
|
|
Loading…
Reference in New Issue