我昨天接受了采访,出现了这个问题:
public class Main {
public static void main(String[] args) {
// Code fragment must prints true if the double variables x and y are both
// strictly between 0 and 1 and false otherwise.
// Assuming args will be always correct (double) input,
// Where's the safety bug?
double x,y;
x = Double.parseDouble(args[0]);
y = Double.parseDouble(args[1]);
System.out.println( (0 < x && x < 1) && (0 < y && y < 1)? true : false );
}
}
我写道,任何地方都没有错误,我的意思是,代码有效。回到家里,试过了,确实有效。但是虽然我确实得到了这份工作,但这个问题是我唯一不好的问题,我无法摆脱它(它看起来很简单)。我相信我什至不明白什么是安全漏洞,那么我的问题是:
什么是安全漏洞,这段代码确实有漏洞吗?
更新:
回复后我放了一些相关资源: