This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/86199] warn on calls to strlen with same argument as in strnlen
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 18 Jun 2018 21:59:33 +0000
- Subject: [Bug tree-optimization/86199] warn on calls to strlen with same argument as in strnlen
- Auto-submitted: auto-generated
- References: <bug-86199-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86199
--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Ditto for strdup vs strndup, although there it might be worth considering
diagnosing only calls where the strndup bound is equal the size of the source
array, as in:
char a[4], *p, *q;
void f (void)
{
p = __builtin_strdup (a); // possibly unsafe? if not then...
// ...
q = __builtin_strndup (a, sizeof a); // this could be replaced by strdup()
}