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

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

use DataHelper.skip() in a few more places

parent 3fce0e8e
No related branches found
No related tags found
No related merge requests found
...@@ -170,8 +170,7 @@ class PeerAcceptor ...@@ -170,8 +170,7 @@ class PeerAcceptor
if (b != PROTO[i]) if (b != PROTO[i])
throw new IOException("Bad protocol 0x" + Integer.toHexString(b) + " at byte " + i); throw new IOException("Bad protocol 0x" + Integer.toHexString(b) + " at byte " + i);
} }
if (in.skip(8) != 8) DataHelper.skip(in, 8);
throw new IOException("EOF before hash");
byte buf[] = new byte[20]; byte buf[] = new byte[20];
int read = DataHelper.read(in, buf); int read = DataHelper.read(in, buf);
if (read != buf.length) if (read != buf.length)
......
...@@ -474,9 +474,7 @@ riCe6OlAEiNpcc6mMyIYYWFICbrDFTrDR3wXqwc/Jkcx6L5VVWoagpSzbo3yGhc= ...@@ -474,9 +474,7 @@ riCe6OlAEiNpcc6mMyIYYWFICbrDFTrDR3wXqwc/Jkcx6L5VVWoagpSzbo3yGhc=
try { try {
fileInputStream = new FileInputStream(signedFile); fileInputStream = new FileInputStream(signedFile);
long skipped = fileInputStream.skip(Signature.SIGNATURE_BYTES); DataHelper.skip(fileInputStream, Signature.SIGNATURE_BYTES);
if (skipped != Signature.SIGNATURE_BYTES)
return "";
byte[] data = new byte[VERSION_BYTES]; byte[] data = new byte[VERSION_BYTES];
int bytesRead = DataHelper.read(fileInputStream, data); int bytesRead = DataHelper.read(fileInputStream, data);
...@@ -515,9 +513,7 @@ riCe6OlAEiNpcc6mMyIYYWFICbrDFTrDR3wXqwc/Jkcx6L5VVWoagpSzbo3yGhc= ...@@ -515,9 +513,7 @@ riCe6OlAEiNpcc6mMyIYYWFICbrDFTrDR3wXqwc/Jkcx6L5VVWoagpSzbo3yGhc=
*/ */
public static String getVersionString(InputStream inputStream) { public static String getVersionString(InputStream inputStream) {
try { try {
long skipped = inputStream.skip(Signature.SIGNATURE_BYTES); DataHelper.skip(inputStream, Signature.SIGNATURE_BYTES);
if (skipped != Signature.SIGNATURE_BYTES)
return "";
byte[] data = new byte[VERSION_BYTES]; byte[] data = new byte[VERSION_BYTES];
int bytesRead = DataHelper.read(inputStream, data); int bytesRead = DataHelper.read(inputStream, data);
...@@ -640,10 +636,8 @@ riCe6OlAEiNpcc6mMyIYYWFICbrDFTrDR3wXqwc/Jkcx6L5VVWoagpSzbo3yGhc= ...@@ -640,10 +636,8 @@ riCe6OlAEiNpcc6mMyIYYWFICbrDFTrDR3wXqwc/Jkcx6L5VVWoagpSzbo3yGhc=
try { try {
fileInputStream = new FileInputStream(signedFile); fileInputStream = new FileInputStream(signedFile);
fileOutputStream = new FileOutputStream(outputFile); fileOutputStream = new FileOutputStream(outputFile);
long skipped = 0;
while (skipped < HEADER_BYTES) DataHelper.skip(fileInputStream, HEADER_BYTES);
skipped += fileInputStream.skip(HEADER_BYTES - skipped);
byte[] buffer = new byte[16*1024]; byte[] buffer = new byte[16*1024];
int bytesRead = 0; int bytesRead = 0;
......
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