title: How to guard against Resource exhaustion and other vulnerabilities?
body: <p>We happened to use IBM appscan <a href="http://www-01.ibm.com/software/awdtools/appscan/" rel="nofollow">http://www-01.ibm.com/software/awdtools/appscan/</a></p>
  
  <p>against our java codebase, and it returned around 3000 high severity vulnerabilities. </p>
  
  <p>Most of them happen to be System Information Leak, which it thinks is happening when we print stack traces in the catch blocks, but we only print the filename and line number it is happening, enabling us to debug the code better. </p>
  
  <p>And some are about SQL injection, input validation etc.</p>
  
  <p>But, my question was about Resource exhaustion (file descriptor, disk space, sockets, ...), and it lists all instances of <code>java.io.BufferedReader.readLine</code> as places for possible external attacks. </p>
  
  <pre><code>       InputStream ins=conn.getInputStream();
  
        String inputLine;
  
        if (!preserveLinefeeds) {
           BufferedReader in = new BufferedReader(new InputStreamReader(ins));
           while ((inputLine = in.readLine()) != null)
              pr.readThreadResponse+=inputLine;
           in.close();
           ins.close();
        } 
  </code></pre>
  
  <p>conn is a HttpURLConnection object.</p>
  
  <p>How do I add safegaurds in the code to prevent this?</p>