[PATCH] D104887: [clang] Evaluate strlen of strcpy argument for -Wfortify-source.

George Burgess IV via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 20 09:51:09 PDT 2021


george.burgess.iv accepted this revision.
george.burgess.iv added a comment.
This revision is now accepted and ready to land.

lgtm -- thanks!

please give a day for other reviewers to add any last minute comments, then i think we can land this.



================
Comment at: clang/lib/Sema/SemaChecking.cpp:739
     DiagID = diag::warn_fortify_source_size_mismatch;
-    SizeIndex = TheCall->getNumArgs() - 1;
-    ObjectIndex = 0;
+    SourceSize = ComputeCheckVariantSize(TheCall->getNumArgs() - 1);
+    DestinationSize = ComputeSizeArgument(0);
----------------
mbenfield wrote:
> george.burgess.iv wrote:
> > i expected `ComputeCheckVariantSize` to imply that the argument was to a `_chk` function, but these `case`s don't reference `_chk` functions (nor do we set `IsChkVariant = true;`). should this be calling `ComputeSizeArgument` instead?
> Maybe the name `ComputeCheckVariantSize` was misleading and it'll be more clear now that I'm changing the name, but these functions like `strncat`, the `memcpy`s below, and `snprintf`, etc, all take an explicit size argument just like the `_chk` functions.
ohh, gotcha. i was misinterpreting the relationship between `IsChkVariant` and `SourceSize` then -- thanks for the clarification!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104887/new/

https://reviews.llvm.org/D104887



More information about the cfe-commits mailing list