зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1475882 - clang-analyzer: Enable clang-analyzer-unix.cstring.BadSizeArg check. r=andi
Check the size argument passed to strncat for common erroneous patterns. There are currently no clang-analyzer-unix.cstring.BadSizeArg warnings in mozilla-central! https://clang-analyzer.llvm.org/available_checks.html MozReview-Commit-ID: DUI3ZNIBoLQ --HG-- extra : source : 8dafc73215cddd2737b4d8dbcb926521736d98c2 extra : histedit_source : ed27a98e47c01c9951c03eb2129ed4997f3cf624
This commit is contained in:
Родитель
4b5276fe8d
Коммит
ced65109b9
|
@ -34,6 +34,8 @@ clang_checkers:
|
|||
publish: !!bool yes
|
||||
- name: clang-analyzer-security.insecureAPI.vfork
|
||||
publish: !!bool yes
|
||||
- name: clang-analyzer-unix.cstring.BadSizeArg
|
||||
publish: !!bool yes
|
||||
- name: misc-argument-comment
|
||||
publish: !!bool yes
|
||||
- name: misc-assert-side-effect
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
// https://clang-analyzer.llvm.org/available_checks.html
|
||||
|
||||
#include "structures.h"
|
||||
|
||||
void test()
|
||||
{
|
||||
char dest[3];
|
||||
strncat(dest, "***", sizeof(dest)); // warning : potential buffer overflow
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
"[[\"warning\", \"Potential buffer overflow. Replace with 'sizeof(dest) - strlen(dest) - 1' or use a safer 'strlcat' API\", \"clang-analyzer-unix.cstring.BadSizeArg\"]]"
|
|
@ -87,3 +87,5 @@ int abort() { return 0; }
|
|||
#define assert(x) \
|
||||
if (!(x)) \
|
||||
(void)abort()
|
||||
|
||||
char *strncat(char *s1, const char *s2, std::size_t n);
|
||||
|
|
Загрузка…
Ссылка в новой задаче