<pre id="vvttv"><mark id="vvttv"><progress id="vvttv"></progress></mark></pre>
    <pre id="vvttv"></pre>

      <p id="vvttv"></p>

          <p id="vvttv"></p>

                <p id="vvttv"></p>

                <pre id="vvttv"><cite id="vvttv"><progress id="vvttv"></progress></cite></pre>

                  <output id="vvttv"><dfn id="vvttv"><th id="vvttv"></th></dfn></output>

                    <p id="vvttv"></p>

                    Missing Check against Null

                    ABSTRACT

                    程序會間接引用一個空指針,因為它不對有可能返回 Null 的函數返回值進行檢查。

                    EXPLANATION

                    幾乎每一個對軟件系統的嚴重攻擊都是從違反程序員的假設開始的。攻擊后,程序員的假設看起來既脆弱又拙劣,但攻擊前,許多程序員會在午休時間為自己的種種假設做很好的辯護。

                    在代碼中很容易發現的兩個可疑的假設是:一是這個函數調用不可能出錯;二是即使出錯了,也不會對系統造成什么重要影響。當程序員忽略函數返回值時,就暗示著自己是基于上述任一假設來執行操作。

                    例 1:以下代碼在使用由 malloc() 返回的指針之前,并沒有檢查內存是否分配成功。


                    buf = (char*) malloc(req_size);
                    strncpy(buf, xfer, req_size);


                    對于這種編碼錯誤的一貫辯解是:

                    “如果我的程序耗盡了所有內存,將必定失敗。當程序試圖間接引用某個空指針時,無論是讓我處理錯誤,還是只是簡單讓程序由于程序分段錯誤而自行崩潰,都沒什么關系。”

                    但是這個解釋忽略了以下三個重要的因素:

                    — 根據應用程序的類型和大小,可能會釋放由其他程序使用的內存,從而使程序繼續運行。

                    — 對于程序來說,它不可能執行適當的退出。如果程序正在執行一個連續性操作,那么它可能會是系統處于一種易變的狀態。

                    — 程序員失去了記下診斷信息的機會。對 malloc() 的調用失敗是不是因為 req_size 太大,還是因為在同一時刻處理的請求太多。或者是由于已累計超時的 memory leak 引起的。如果不對錯誤進行處理,就不會知道是什么原因。

                    REFERENCES

                    [1] Standards Mapping - OWASP Top 10 2004 - (OWASP 2004) A9 Application Denial of Service

                    [2] Standards Mapping - Security Technical Implementation Guide Version 3 - (STIG 3) APP3120 CAT II, APP6080 CAT II

                    [3] Standards Mapping - Security Technical Implementation Guide Version 3.4 - (STIG 3.4) APP3120 CAT II, APP6080 CAT II

                    [4] J. Viega, G. McGraw Building Secure Software Addison-Wesley

                    [5] Standards Mapping - Common Weakness Enumeration - (CWE) CWE ID 253, CWE ID 690

                    [6] Standards Mapping - Payment Card Industry Data Security Standard Version 1.1 - (PCI 1.1) Requirement 6.5.9


                    Copyright 2013 Fortify Software - All rights reserved.
                    (Generated from version 2013.1.1.0008 of the Fortify Secure Coding Rulepacks)
                    desc.controlflow.cpp.missing_check_against_null

                      <pre id="vvttv"><mark id="vvttv"><progress id="vvttv"></progress></mark></pre>
                      <pre id="vvttv"></pre>

                        <p id="vvttv"></p>

                            <p id="vvttv"></p>

                                  <p id="vvttv"></p>

                                  <pre id="vvttv"><cite id="vvttv"><progress id="vvttv"></progress></cite></pre>

                                    <output id="vvttv"><dfn id="vvttv"><th id="vvttv"></th></dfn></output>

                                      <p id="vvttv"></p>

                                      这里只有精品视频