From 8ed280ebf42e5d11d8f4df8eccb341f82d075830 Mon Sep 17 00:00:00 2001
From: zzz <zzz@mail.i2p>
Date: Tue, 9 Oct 2012 10:14:56 +0000
Subject: [PATCH]  * RouterInfo: Exit 1 on error in main()

---
 core/java/src/net/i2p/data/RouterInfo.java | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/core/java/src/net/i2p/data/RouterInfo.java b/core/java/src/net/i2p/data/RouterInfo.java
index b38d5f6a05..9f980716f5 100644
--- a/core/java/src/net/i2p/data/RouterInfo.java
+++ b/core/java/src/net/i2p/data/RouterInfo.java
@@ -637,7 +637,8 @@ public class RouterInfo extends DatabaseEntry {
     }
 
     /**
-     *  Print out routerinfos from files specified on the command line
+     *  Print out routerinfos from files specified on the command line.
+     *  Exits 1 if any RI is invalid, fails signature, etc.
      *  @since 0.8
      */
     public static void main(String[] args) {
@@ -645,23 +646,29 @@ public class RouterInfo extends DatabaseEntry {
             System.err.println("Usage: RouterInfo file ...");
             System.exit(1);
         }
+        boolean fail = false;
         for (int i = 0; i < args.length; i++) {
              RouterInfo ri = new RouterInfo();
              InputStream is = null;
              try {
                  is = new java.io.FileInputStream(args[i]);
                  ri.readBytes(is);
-                 if (ri.isValid())
+                 if (ri.isValid()) {
                      System.out.println(ri.toString());
-                 else
+                  } else {
                      System.err.println("Router info " + args[i] + " is invalid");
+                     fail = true;
+                  }
              } catch (Exception e) {
                  System.err.println("Error reading " + args[i] + ": " + e);
+                 fail = true;
              } finally {
                  if (is != null) {
                      try { is.close(); } catch (IOException ioe) {}
                  }
              }
         }
+        if (fail)
+            System.exit(1);
     }
 }
-- 
GitLab