diff options
author | Balazs Benics <benicsbalazs@gmail.com> | 2020-11-30 18:06:28 +0100 |
---|---|---|
committer | Balazs Benics <benicsbalazs@gmail.com> | 2020-11-30 18:06:28 +0100 |
commit | ee073c798515e56b23463391a7b40d5ee6527337 (patch) | |
tree | 907bf4fb889cc7c60c82a25956c81cf4bf8e2dd9 /clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp | |
parent | abfbc5579bd4507ae286d4f29f8a157de0629372 (diff) | |
download | llvm-ee073c798515e56b23463391a7b40d5ee6527337.zip llvm-ee073c798515e56b23463391a7b40d5ee6527337.tar.gz llvm-ee073c798515e56b23463391a7b40d5ee6527337.tar.bz2 |
[analyzer][StdLibraryFunctionsChecker] Fix typos in summaries of mmap and mmap64
The fd parameter of
```
void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset)
```
should be constrained to the range [0, IntMax] as that is of type int.
Constraining to the range [0, Off_tMax] would result in a crash as that is
of a signed type with the value of 0xff..f (-1).
The crash would happen when we try to apply the arg constraints.
At line 583: assert(Min <= Max), as 0 <= -1 is not satisfied
The mmap64 is fixed for the same reason.
Reviewed By: martong, vsavchenko
Differential Revision: https://reviews.llvm.org/D92307
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp index 10011ef..f8eafde 100644 --- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp @@ -1722,7 +1722,6 @@ void StdLibraryFunctionsChecker::initFunctionSummaries( "ftello", Signature(ArgTypes{FilePtrTy}, RetType{Off_tTy}), Summary(NoEvalCall).ArgConstraint(NotNull(ArgNo(0)))); - Optional<RangeInt> Off_tMax = getMaxValue(Off_tTy); // void *mmap(void *addr, size_t length, int prot, int flags, int fd, // off_t offset); addToFunctionSummaryMap( @@ -1732,10 +1731,9 @@ void StdLibraryFunctionsChecker::initFunctionSummaries( Summary(NoEvalCall) .ArgConstraint(ArgumentCondition(1, WithinRange, Range(1, SizeMax))) .ArgConstraint( - ArgumentCondition(4, WithinRange, Range(0, Off_tMax)))); + ArgumentCondition(4, WithinRange, Range(0, IntMax)))); Optional<QualType> Off64_tTy = lookupTy("off64_t"); - Optional<RangeInt> Off64_tMax = getMaxValue(Off_tTy); // void *mmap64(void *addr, size_t length, int prot, int flags, int fd, // off64_t offset); addToFunctionSummaryMap( @@ -1745,7 +1743,7 @@ void StdLibraryFunctionsChecker::initFunctionSummaries( Summary(NoEvalCall) .ArgConstraint(ArgumentCondition(1, WithinRange, Range(1, SizeMax))) .ArgConstraint( - ArgumentCondition(4, WithinRange, Range(0, Off64_tMax)))); + ArgumentCondition(4, WithinRange, Range(0, IntMax)))); // int pipe(int fildes[2]); addToFunctionSummaryMap( |