Skip to content

Commit 09b31c1

Browse files
author
augustd
committed
Small change to avoid AIOOBE when converting from Reader into InputStream in constructor
1 parent 6d56a56 commit 09b31c1

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/main/java/org/owasp/esapi/reference/crypto/ReferenceEncryptedProperties.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ public void load(InputStream in) throws IOException {
179179
@Override
180180
public void load(Reader in) throws IOException {
181181

182+
if (in == null) return;
183+
182184
//read from the reader into a StringBuffer
183185
char[] cbuf = new char[65536];
184186
BufferedReader buff = new BufferedReader(in);
@@ -187,7 +189,7 @@ public void load(Reader in) throws IOException {
187189
int read_this_time = 0;
188190
while (read_this_time != -1) {
189191
read_this_time = buff.read(cbuf, 0, 65536);
190-
contents.append(cbuf, 0, read_this_time);
192+
if (read_this_time > 0) contents.append(cbuf, 0, read_this_time);
191193
}
192194

193195
//create a new InputStream from the StringBuffer

0 commit comments

Comments
 (0)