Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Edited by sciSpider Java v3.0

...

Code Block
bgColor#FFcccc
public void readSensitiveFile() {
  try {
    SecurityManager sm = System.getSecurityManager();
    if(sm != null) {  // Check if file can be read
      sm.checkRead(""/temp/tempFile"");
    } 
    // Access the file
  } catch (SecurityException se) { 
    // Log exception  
  }
}

...

Code Block
bgColor#ccccff
public final void readSensitiveFile() {
  try {
    SecurityManager sm = System.getSecurityManager();
    if(sm != null) {  // check if file can be read
      sm.checkRead(""/temp/tempFile"");
    } 
    // Access the file
  } catch (SecurityException se) { 
    // Log exception 
  }
}

...

Code Block
bgColor#ccccff
private void readSensitiveFile() {
  try {
    SecurityManager sm = System.getSecurityManager();
    if(sm != null) {  // check if file can be read
      sm.checkRead(""/temp/tempFile"");
    } 
    // Access the file
  } catch (SecurityException se) { 
    // Log exception 
  }
}

...

Search for vulnerabilities resulting from the violation of this rule on the CERT website.

References

Wiki Markup
\[[Ware 08|AA. Java References#Ware 08]\]

...

MET05-J. Validate method parameters            12. Methods (MET)            MET30-J. Follow the general contract while overriding the equals method