[analyzer][StdLibraryFunctionsChecker] Fix typos in summaries of mmap and mmap64
authorBalazs Benics <benicsbalazs@gmail.com>
Mon, 30 Nov 2020 17:06:28 +0000 (18:06 +0100)
committerBalazs Benics <benicsbalazs@gmail.com>
Mon, 30 Nov 2020 17:06:28 +0000 (18:06 +0100)
commitee073c798515e56b23463391a7b40d5ee6527337
tree907bf4fb889cc7c60c82a25956c81cf4bf8e2dd9
parentabfbc5579bd4507ae286d4f29f8a157de0629372
[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
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
clang/test/Analysis/std-c-library-posix-crash.c [new file with mode: 0644]