Skip to content

Commit faa181a

Browse files
committed
Another merge 'main' into 'llt-fpinfo'
2 parents 6e90070 + a80c393 commit faa181a

File tree

97 files changed

+962
-978
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+962
-978
lines changed

clang/docs/analyzer/checkers.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1859,6 +1859,32 @@ this) and always check the return value of these calls.
18591859
18601860
This check corresponds to SEI CERT Rule `POS36-C <https://wiki.sei.cmu.edu/confluence/display/c/POS36-C.+Observe+correct+revocation+order+while+relinquishing+privileges>`_.
18611861
1862+
.. _security-VAList:
1863+
1864+
security.VAList (C, C++)
1865+
""""""""""""""""""""""""
1866+
Reports use of uninitialized (or already released) ``va_list`` objects and
1867+
situations where a ``va_start`` call is not followed by ``va_end``.
1868+
1869+
Report out of bounds access to memory that is before the start or after the end
1870+
of the accessed region (array, heap-allocated region, string literal etc.).
1871+
This usually means incorrect indexing, but the checker also detects access via
1872+
the operators ``*`` and ``->``.
1873+
1874+
.. code-block:: c
1875+
1876+
int test_use_after_release(int x, ...) {
1877+
va_list va;
1878+
va_start(va, x);
1879+
va_end(va);
1880+
return va_arg(va, int); // warn: va is uninitialized
1881+
}
1882+
1883+
void test_leak(int x, ...) {
1884+
va_list va;
1885+
va_start(va, x);
1886+
} // warn: va is leaked
1887+
18621888
.. _unix-checkers:
18631889
18641890
unix

clang/include/clang/StaticAnalyzer/Checkers/Checkers.td

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ def Cplusplus : Package<"cplusplus">;
6464
def CplusplusAlpha : Package<"cplusplus">, ParentPackage<Alpha>;
6565
def CplusplusOptIn : Package<"cplusplus">, ParentPackage<OptIn>;
6666

67-
def Valist : Package<"valist">;
68-
6967
def DeadCode : Package<"deadcode">;
7068
def DeadCodeAlpha : Package<"deadcode">, ParentPackage<Alpha>;
7169

@@ -779,35 +777,6 @@ def SmartPtrChecker: Checker<"SmartPtr">,
779777

780778
} // end: "alpha.cplusplus"
781779

782-
783-
//===----------------------------------------------------------------------===//
784-
// Valist checkers.
785-
//===----------------------------------------------------------------------===//
786-
787-
let ParentPackage = Valist in {
788-
789-
def ValistBase : Checker<"ValistBase">,
790-
HelpText<"Gathers information about va_lists.">,
791-
Documentation<NotDocumented>,
792-
Hidden;
793-
794-
def UninitializedChecker : Checker<"Uninitialized">,
795-
HelpText<"Check for usages of uninitialized (or already released) va_lists.">,
796-
Dependencies<[ValistBase]>,
797-
Documentation<NotDocumented>;
798-
799-
def UnterminatedChecker : Checker<"Unterminated">,
800-
HelpText<"Check for va_lists which are not released by a va_end call.">,
801-
Dependencies<[ValistBase]>,
802-
Documentation<NotDocumented>;
803-
804-
def CopyToSelfChecker : Checker<"CopyToSelf">,
805-
HelpText<"Check for va_lists which are copied onto itself.">,
806-
Dependencies<[ValistBase]>,
807-
Documentation<NotDocumented>;
808-
809-
} // end : "valist"
810-
811780
//===----------------------------------------------------------------------===//
812781
// Deadcode checkers.
813782
//===----------------------------------------------------------------------===//
@@ -982,6 +951,10 @@ let ParentPackage = Security in {
982951
"'setuid(getuid())' (CERT: POS36-C)">,
983952
Documentation<HasDocumentation>;
984953

954+
def VAListChecker : Checker<"VAList">,
955+
HelpText<"Warn on misuse of va_list objects">,
956+
Documentation<HasDocumentation>;
957+
985958
} // end "security"
986959

987960
let ParentPackage = ENV in {

0 commit comments

Comments
 (0)