Cppcheck顯示scanf函數如下警告:scanf函數Cppcheck警告
Message: scanf without field width limits can crash with huge input data. To fix this error message add a field width specifier: %s => %20s %i => %3i Sample program that can crash: #include int main() { int a; scanf("%i", &a); return 0; } To make it crash: perl -e 'print "5"x2100000' | ./a.out
我不能崩潰這個程序輸入「巨大的輸入數據」。我應該輸入什麼來獲得這次崩潰?我也弄不明白這個警告的最後一行的含義是:
的perl -e ...
「按任意鍵繼續。」 「任何鑰匙在哪裏?」 – Dave
@Dave:?????你的評論看起來像垃圾郵件:( –
什麼?不是。按照你的問題的措辭,看起來你錯誤地理解了「巨大的輸入數據」這個短語 - 這不是你輸入的內容,而是輸入的屬性。與經典的任何關鍵笑話都是一樣的,我用這個笑話來比喻你的問題。 – Dave