The new signature validating code was failing to close its files properly which
was causing some freakout.
This commit is contained in:
@@ -893,8 +893,8 @@ public class Application
|
|||||||
if (_digest.validateResource(crsrc, null)) {
|
if (_digest.validateResource(crsrc, null)) {
|
||||||
init(true);
|
init(true);
|
||||||
} else {
|
} else {
|
||||||
Log.warning(CONFIG_FILE + " failed to validate even after " +
|
Log.warning(CONFIG_FILE + " failed to validate even after redownloading. " +
|
||||||
"redownloading. Blindly forging onward.");
|
"Blindly forging onward.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1038,14 +1038,15 @@ public class Application
|
|||||||
} else {
|
} else {
|
||||||
File signatureFile = downloadFile(path + SIGNATURE_SUFFIX);
|
File signatureFile = downloadFile(path + SIGNATURE_SUFFIX);
|
||||||
byte[] signature = null;
|
byte[] signature = null;
|
||||||
|
FileReader reader = null;
|
||||||
try {
|
try {
|
||||||
signature = IOUtils.toByteArray(new FileReader(signatureFile), "utf8");
|
reader = new FileReader(signatureFile);
|
||||||
|
signature = IOUtils.toByteArray(reader, "utf8");
|
||||||
} finally {
|
} finally {
|
||||||
// delete the file regardless
|
StreamUtil.close(reader);
|
||||||
signatureFile.delete();
|
signatureFile.delete(); // delete the file regardless
|
||||||
}
|
}
|
||||||
|
|
||||||
FileInputStream dataInput = new FileInputStream(target);
|
|
||||||
byte[] buffer = new byte[8192];
|
byte[] buffer = new byte[8192];
|
||||||
int length, validated = 0;
|
int length, validated = 0;
|
||||||
for (Object signer : _signers) {
|
for (Object signer : _signers) {
|
||||||
@@ -1054,7 +1055,9 @@ public class Application
|
|||||||
}
|
}
|
||||||
|
|
||||||
Certificate cert = (Certificate)signer;
|
Certificate cert = (Certificate)signer;
|
||||||
|
FileInputStream dataInput = null;
|
||||||
try {
|
try {
|
||||||
|
dataInput = new FileInputStream(target);
|
||||||
Signature sig = Signature.getInstance("SHA1withRSA");
|
Signature sig = Signature.getInstance("SHA1withRSA");
|
||||||
sig.initVerify(cert);
|
sig.initVerify(cert);
|
||||||
while ((length = dataInput.read(buffer)) != -1) {
|
while ((length = dataInput.read(buffer)) != -1) {
|
||||||
@@ -1069,8 +1072,15 @@ public class Application
|
|||||||
validated++;
|
validated++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
Log.warning("Failure validating signature of " + target + ": " + ioe);
|
||||||
|
|
||||||
} catch (GeneralSecurityException gse) {
|
} catch (GeneralSecurityException gse) {
|
||||||
// no problem!
|
// no problem!
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
StreamUtil.close(dataInput);
|
||||||
|
dataInput = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1083,15 +1093,8 @@ public class Application
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// move the old file to a _old version
|
|
||||||
File original = getLocalPath(path);
|
|
||||||
if (original.exists()) {
|
|
||||||
if (!FileUtil.renameTo(original, getLocalPath(path + "_old"))) {
|
|
||||||
Log.warning("Failed to move " + original + " to backup.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// now move the temporary file over the original
|
// now move the temporary file over the original
|
||||||
|
File original = getLocalPath(path);
|
||||||
if (!FileUtil.renameTo(target, original)) {
|
if (!FileUtil.renameTo(target, original)) {
|
||||||
throw new IOException("Failed to rename(" + target + ", " + original + ")");
|
throw new IOException("Failed to rename(" + target + ", " + original + ")");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user