[analyzer][StdLibraryFunctionsChecker] Elaborate the summary of fread and fwrite
authorGabor Marton <gabor.marton@ericsson.com>
Thu, 3 Sep 2020 11:23:49 +0000 (13:23 +0200)
committerGabor Marton <gabor.marton@ericsson.com>
Tue, 15 Sep 2020 14:35:39 +0000 (16:35 +0200)
commita012bc4c42e4408a18e4c4d67306b79c576df961
treee6b953bba529bb408767f221e515a9ba07baf05d
parente328456a9e6fa8c1ef05e183c1506ed837005847
[analyzer][StdLibraryFunctionsChecker] Elaborate the summary of fread and fwrite

Add the BufferSize argument constraint to fread and fwrite. This change
itself makes it possible to discover a security critical case, described
in SEI-CERT ARR38-C.

We also add the not-null constraint on the 3rd arguments.

In this patch, I also remove those lambdas that don't take any
parameters (Fwrite, Fread, Getc), thus making the code better
structured.

Differential Revision: https://reviews.llvm.org/D87081
clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
clang/test/Analysis/Inputs/system-header-simulator.h
clang/test/Analysis/analyzer-enabled-checkers.c
clang/test/Analysis/std-c-library-functions-arg-constraints.c
clang/test/Analysis/std-c-library-functions-vs-stream-checker.c [new file with mode: 0644]