<dd id="sga4y"><optgroup id="sga4y"></optgroup></dd>
<nav id="sga4y"><code id="sga4y"></code></nav>
  • <optgroup id="sga4y"></optgroup>

    Code Correctness: Macro Misuse

    ABSTRACT

    對于在共享資源上運行且在部分平臺上作為宏執行的函數系列,必須在相同的程序范圍內進行調用。

    EXPLANATION

    有些函數家族在有些平臺上作為函數執行,而在其他平臺上作為宏執行。如果函數依賴于某個內部維護的(而不是在調用時傳入的)共享資源,則它們必須在同一程序范圍內使用,否則會無法訪問該共享資源。

    例 1:以下代碼使用 pthread_cleanup_push() 函數將 routine 函數推至調用線程清除堆棧之上,然后返回。由于 pthread_cleanup_push() 和它的搭檔函數 pthread_cleanup_pop() 在 IBM AIX 之外的平臺上作為宏來執行,因此后面的 pthread_cleanup_pop() 調用將無法訪問 pthread_cleanup_push() 創建的數據結構。在將這些函數作為宏執行的平臺上,該代碼將無法編譯,或者不能正確運行。


    void helper() {
    ...
    pthread_cleanup_push(routine, arg);
    }

    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) APP6080 CAT II

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

    [4] Standards Mapping - Common Weakness Enumeration - (CWE) CWE ID 730

    [5] 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.code_correctness_macro_misuse

    97av