[PATCH] D124659: [analyzer][docs] Document alpha.security.cert.pos.34c limitations
Balázs Benics via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon May 2 01:37:55 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG464c9833df80: [analyzer][docs] Document alpha.security.cert.pos.34c limitations (authored by steakhal).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D124659/new/
https://reviews.llvm.org/D124659
Files:
clang/docs/analyzer/checkers.rst
Index: clang/docs/analyzer/checkers.rst
===================================================================
--- clang/docs/analyzer/checkers.rst
+++ clang/docs/analyzer/checkers.rst
@@ -2268,6 +2268,25 @@
return putenv(env); // putenv function should not be called with auto variables
}
+Limitations:
+
+ - Technically, one can pass automatic variables to ``putenv``,
+ but one needs to ensure that the given environment key stays
+ alive until it's removed or overwritten.
+ Since the analyzer cannot keep track of which envvars get overwritten
+ and when, it needs to be slightly more aggressive and warn for such
+ cases too, leading in some cases to false-positive reports like this:
+
+ .. code-block:: c
+
+ void baz() {
+ char env[] = "NAME=value";
+ putenv(env); // false-positive warning: putenv function should not be called...
+ // More code...
+ putenv((char *)"NAME=anothervalue");
+ // This putenv call overwrites the previous entry, thus that can no longer dangle.
+ } // 'env' array becomes dead only here.
+
alpha.security.cert.env
^^^^^^^^^^^^^^^^^^^^^^^
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124659.426354.patch
Type: text/x-patch
Size: 1172 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220502/9d3f7f38/attachment.bin>
More information about the cfe-commits
mailing list