我使用Fortify掃描我的代碼後,出現「不安全的JNI(輸入驗證和表示,語義)」問題。我提到了Fortify的建議,並在網站上搜索了一些解決方案,但我無法解決這個問題。在Android Studio中強化掃描問題
我遵循Fortify在website推薦的兼容解決方案。 我甚至使用Fortify從網站掃描推薦的代碼,並得到相同的問題。
我的代碼如下所示:
public final class JNI_Related {
// JNI
public native FileDescriptor open(String path, int baudrate, int data_bits, char parity, int stop_bits);
public native void close();
public FileDescriptor DoOpen(String mPath, int mBaudrate, int mData_bits, char mParity, int mStop_bits){
if(mmPath.length() == 0){
throw new NullPointerException();
}
if((mmBaudrate < 0) || (mmData_bits < 0) || (mmStop_bits < 0) || (mmParity == 'a')){
throw new IllegalArgumentException();
}
mFd = open(mmPath, mmBaudrate, mmData_bits, mmParity, mmStop_bits);
if(mFd == null){
throw new IllegalArgumentException();
}
return mFd;
}
public void DoClose(){
close();
}
static {
System.loadLibrary("jniutill");
}
}
我真的需要一些幫助!
您是否曾經爲此找到答案? –