================ @@ -2516,12 +2516,15 @@ void StdLibraryFunctionsChecker::initFunctionSummaries( .ArgConstraint(NotNull(ArgNo(0)))); // char *getcwd(char *buf, size_t size); - // FIXME: Improve for errno modeling. addToFunctionSummaryMap( "getcwd", Signature(ArgTypes{CharPtrTy, SizeTy}, RetType{CharPtrTy}), Summary(NoEvalCall) + .Case({ReturnValueCondition(BO_EQ, ArgNo(0))}, + ErrnoMustNotBeChecked, GenericSuccessMsg) + .Case({IsNull(Ret)}, ErrnoNEZeroIrrelevant, GenericFailureMsg) + .ArgConstraint(NotNull(ArgNo(0))) .ArgConstraint( - ArgumentCondition(1, WithinRange, Range(0, SizeMax)))); + ArgumentCondition(1, WithinRange, Range(1, SizeMax)))); ---------------- balazske wrote:
Here a `BufferSize` type of constraint can be used additionally. See `readlink` for example. Value 0 is allowed for the size. Passing 0 is not undefined behavior, the function shall fail and set `errno`. A new case can be added (like at `readlink`). https://github.com/llvm/llvm-project/pull/77040 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits