Skip to content

Commit

Permalink
[clang][analyzer] Fix incorrect range of 'ftell' in the StdLibraryFun…
Browse files Browse the repository at this point in the history
…ctionsChecker (#77576)

According to https://pubs.opengroup.org/onlinepubs/9699919799/, the
return value of `ftell` is not restricted to `> 0`, and may return `0`
in real world.
  • Loading branch information
benshi001 committed Jan 11, 2024
1 parent 753dc0a commit 66d022f
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2274,7 +2274,7 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
addToFunctionSummaryMap(
"ftell", Signature(ArgTypes{FilePtrTy}, RetType{LongTy}),
Summary(NoEvalCall)
.Case({ReturnValueCondition(WithinRange, Range(1, LongMax))},
.Case({ReturnValueCondition(WithinRange, Range(0, LongMax))},
ErrnoUnchanged, GenericSuccessMsg)
.Case(ReturnsMinusOne, ErrnoNEZeroIrrelevant, GenericFailureMsg)
.ArgConstraint(NotNull(ArgNo(0))));
Expand Down

0 comments on commit 66d022f

Please sign in to comment.