code: public static Document readLog(File logDir, String callpath)
              throws Exception {
          File dir = new File(logDir, callpath);
          File f = new File(dir, "log.xml");
          if (f.exists()) {
              DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
              dbf.setNamespaceAware(true);
  		 // Fortify Mod: Disable entity expansion to foil External Entity Injections
  		 dbf.setExpandEntityReferences(false);
              DocumentBuilder db = dbf.newDocumentBuilder();
              Document doc = db.newDocument();
              TransformerFactory tf = TransformerFactory.newInstance();
         	     // Fortify Mod: prevent external entity injection
              tf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
              Transformer t = tf.newTransformer();
              t.setErrorListener(new com.occamlab.te.NullErrorListener());
              try {
                  t.transform(new StreamSource(f), new DOMResult(doc));
              } catch (Exception e) {
                  // The log may not have been closed properly.
                  // Try again with a closing </log> tag
                  RandomAccessFile raf = new RandomAccessFile(f, "r");
                  int l = new Long(raf.length()).intValue();
                  byte[] buf = new byte[l + 8];
                  raf.read(buf);
                  raf.close();
                  buf[l] = '\n';
                  buf[l + 1] = '<';
                  buf[l + 2] = '/';
                  buf[l + 3] = 'l';
                  buf[l + 4] = 'o';
                  buf[l + 5] = 'g';
                  buf[l + 6] = '>';
                  buf[l + 7] = '\n';
                  doc = db.newDocument();
                  tf.newTransformer().transform(
                          new StreamSource(new ByteArrayInputStream(buf)),
                          new DOMResult(doc));
              }
              return doc;
          } else {
              return null;
          }
      }
docs: Reads a log from disk