From aaaf437d6204238f0d4e01729efa5c59426b27e4 Mon Sep 17 00:00:00 2001 From: jrandom Date: Wed, 27 Jul 2005 20:15:35 +0000 Subject: [PATCH] skip properly (DataHelper.read confusion) --- core/java/src/net/i2p/crypto/TrustedUpdate.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/core/java/src/net/i2p/crypto/TrustedUpdate.java b/core/java/src/net/i2p/crypto/TrustedUpdate.java index 0f34d5f47..fa2ebc6e8 100644 --- a/core/java/src/net/i2p/crypto/TrustedUpdate.java +++ b/core/java/src/net/i2p/crypto/TrustedUpdate.java @@ -287,15 +287,20 @@ jP69nPbh4KLGhF+SD0+0bW4= try { fileInputStream = new FileInputStream(signedFile); - byte[] data = new byte[VERSION_BYTES]; - int bytesRead = DataHelper.read(fileInputStream, data, Signature.SIGNATURE_BYTES, VERSION_BYTES); - - if (bytesRead != VERSION_BYTES) + long skipped = fileInputStream.skip(Signature.SIGNATURE_BYTES); + if (skipped != Signature.SIGNATURE_BYTES) return ""; + byte[] data = new byte[VERSION_BYTES]; + int bytesRead = DataHelper.read(fileInputStream, data); + + if (bytesRead != VERSION_BYTES) { + return ""; + } for (int i = 0; i < VERSION_BYTES; i++) - if (data[i] == 0x00) + if (data[i] == 0x00) { return new String(data, 0, i, "UTF-8"); + } return new String(data, "UTF-8"); } catch (UnsupportedEncodingException uee) {