Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protect readLine() against DoS #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<versions.java-security-toolkit>1.1.1</versions.java-security-toolkit>
</properties>



Expand Down Expand Up @@ -72,7 +73,11 @@
<version>2.9.7</version>
</dependency -->

</dependencies>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This library holds security tools for protecting Java API calls.

License: MIT ✅ | Open source ✅ | More facts

<dependency>
<groupId>io.github.pixee</groupId>
<artifactId>java-security-toolkit</artifactId>
</dependency>
</dependencies>

<!-- build>
<finalName>cryptoFXWallet</finalName>
Expand Down Expand Up @@ -121,4 +126,13 @@
</plugins>
</build -->

</project>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.github.pixee</groupId>
<artifactId>java-security-toolkit</artifactId>
<version>${versions.java-security-toolkit}</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

package com.donlaiq.coin.properties;

import io.github.pixee.security.BoundedLineReader;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
Expand Down Expand Up @@ -34,12 +35,12 @@ private GlobalProperties()
try
{
reader = new BufferedReader(new FileReader(GlobalProperties.class.getClassLoader().getResource("resources/setup.properties").getPath()));
String line = reader.readLine();
String line = BoundedLineReader.readLine(reader, 5_000_000);
while(line != null)
{
String[] splitLine = line.split("=");
setupMap.put(splitLine[0], splitLine[1]);
line = reader.readLine();
line = BoundedLineReader.readLine(reader, 5_000_000);
}
reader.close();
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/com/donlaiq/controller/WalletController.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

package com.donlaiq.controller;

import io.github.pixee.security.BoundedLineReader;
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
Expand Down Expand Up @@ -667,11 +668,11 @@ protected void importAddresses(ActionEvent event)
List<String> lines = new ArrayList<String>();
FileInputStream fileReader = new FileInputStream(file);
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(fileReader, "UTF-8"));
String line = bufferedReader.readLine();
String line = BoundedLineReader.readLine(bufferedReader, 5_000_000);
while(line != null)
{
lines.add(line);
line = bufferedReader.readLine();
line = BoundedLineReader.readLine(bufferedReader, 5_000_000);
}

bufferedReader.close();
Expand Down