fix handling of IOExceptions when reading zone files (#20)
* fix handling of ioexceptions when reading zone files * bump the version
This commit is contained in:
@@ -240,7 +240,12 @@ public class SignKeyset extends CLBase {
|
||||
|
||||
public void execute() throws Exception {
|
||||
// Read in the zone
|
||||
List<Record> records = ZoneUtils.readZoneFile(inputfile, null);
|
||||
List<Record> records = null;
|
||||
try {
|
||||
records = ZoneUtils.readZoneFile(inputfile, null);
|
||||
} catch (java.io.IOException e) {
|
||||
fail("Unable to read input file: " + e.getMessage());
|
||||
}
|
||||
if (records == null || records.isEmpty()) {
|
||||
fail("empty keyset file");
|
||||
}
|
||||
|
||||
@@ -211,7 +211,12 @@ public class SignRRset extends CLBase {
|
||||
|
||||
public void execute() throws Exception {
|
||||
// Read in the zone
|
||||
List<Record> records = ZoneUtils.readZoneFile(inputfile, null);
|
||||
List<Record> records = null;
|
||||
try {
|
||||
records = ZoneUtils.readZoneFile(inputfile, null);
|
||||
} catch (java.io.IOException e) {
|
||||
fail("Unable to read input file: " + e.getMessage());
|
||||
}
|
||||
if (records == null || records.isEmpty()) {
|
||||
fail("empty RRset file");
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class SignZone extends CLBase {
|
||||
private boolean fullySignKeyset = false;
|
||||
private List<Name> includeNames = null;
|
||||
private boolean useNsec3 = false;
|
||||
private byte[] salt = null;
|
||||
private byte[] salt = {};
|
||||
private int iterations = 0;
|
||||
private int digestId = DNSSEC.Digest.SHA256;
|
||||
private long nsec3paramttl = -1;
|
||||
@@ -161,7 +161,7 @@ public class SignZone extends CLBase {
|
||||
start = Instant.now().minusSeconds(3600);
|
||||
}
|
||||
} catch (java.text.ParseException e) {
|
||||
fail("unable to parse start time specifiction: " + e);
|
||||
fail("unable to parse start time specifiction: " + e.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -172,7 +172,7 @@ public class SignZone extends CLBase {
|
||||
expire = Utils.convertDuration(start, "+2592000"); // 30 days
|
||||
}
|
||||
} catch (java.text.ParseException e) {
|
||||
fail("missing zone file and/or key files");
|
||||
fail("unable to parse end time specficiation: " + e.getMessage());
|
||||
}
|
||||
|
||||
outputfile = cli.getOptionValue('f');
|
||||
|
||||
@@ -100,7 +100,15 @@ public class VerifyZone extends CLBase {
|
||||
zoneverifier.getVerifier().setCurrentTime(currentTime);
|
||||
zoneverifier.setIgnoreDuplicateRRs(ignoreDups);
|
||||
|
||||
List<Record> records = ZoneUtils.readZoneFile(zonefile, null);
|
||||
List<Record> records = null;
|
||||
try {
|
||||
records = ZoneUtils.readZoneFile(zonefile, null);
|
||||
} catch (java.io.IOException e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
if (records == null) {
|
||||
fail("Unable to read a zone file");
|
||||
}
|
||||
|
||||
log.fine("verifying zone...");
|
||||
int errors = zoneverifier.verifyZone(records);
|
||||
|
||||
@@ -58,13 +58,10 @@ public class ZoneUtils {
|
||||
*/
|
||||
public static List<Record> readZoneFile(String zonefile, Name origin) throws IOException {
|
||||
ArrayList<Record> records = new ArrayList<>();
|
||||
try (Master m = zonefile.equals("-") ? new Master(System.in) : new Master(zonefile, origin)) {
|
||||
Record r = null;
|
||||
while ((r = m.nextRecord()) != null) {
|
||||
records.add(r);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Master m = zonefile.equals("-") ? new Master(System.in) : new Master(zonefile, origin);
|
||||
Record r = null;
|
||||
while ((r = m.nextRecord()) != null) {
|
||||
records.add(r);
|
||||
}
|
||||
|
||||
return records;
|
||||
|
||||
Reference in New Issue
Block a user