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

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

Fix readLong() bug where it wasnt throwing an exception on EOF

parent 4aa9c7fd
No related branches found
No related tags found
No related merge requests found
...@@ -344,8 +344,9 @@ public class DataHelper { ...@@ -344,8 +344,9 @@ public class DataHelper {
long rv = 0; long rv = 0;
for (int i = 0; i < numBytes; i++) { for (int i = 0; i < numBytes; i++) {
long cur = rawStream.read() & 0xFF; long cur = rawStream.read();
if (cur == -1) throw new DataFormatException("Not enough bytes for the field"); if (cur == -1) throw new DataFormatException("Not enough bytes for the field");
cur &= 0xFF;
// we loop until we find a nonzero byte (or we reach the end) // we loop until we find a nonzero byte (or we reach the end)
if (cur != 0) { if (cur != 0) {
// ok, data found, now iterate through it to fill the rv // ok, data found, now iterate through it to fill the rv
...@@ -355,9 +356,10 @@ public class DataHelper { ...@@ -355,9 +356,10 @@ public class DataHelper {
cur = cur << shiftAmount; cur = cur << shiftAmount;
rv += cur; rv += cur;
if (j + 1 < remaining) { if (j + 1 < remaining) {
cur = rawStream.read() & 0xFF; cur = rawStream.read();
if (cur == -1) if (cur == -1)
throw new DataFormatException("Not enough bytes for the field"); throw new DataFormatException("Not enough bytes for the field");
cur &= 0xFF;
} }
} }
break; break;
......
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