Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#FFcccc
// Trusted.java

import java.security.*;

public class Trusted {

   public static void loadLibrary(final String library){
      AccessController.doPrivileged(new PrivilegedAction<Void>() {
         public Void run() {
             System.loadLibrary(library);
             return null;
         }
      });
   }
}

---------------------------------------------------------------------------------

// Untrusted.java

public class Untrusted {

   private native void bufferOverflowmyMethod();

   public static void main(String[] args) {
      String library = new String("BufferOverflowMyLib");
      Trusted.loadLibrary(library);
      new Untrusted.bufferOverflowmyMethod();  // invoke the native method
   }
}

...