public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <jeffreyalaw@gmail.com>
To: Siddhesh Poyarekar <siddhesh@gotplt.org>, gcc-patches@gcc.gnu.org
Cc: jakub@redhat.com
Subject: Re: [PATCH v2] tree-object-size: Support strndup and strdup
Date: Sun, 20 Nov 2022 08:42:22 -0700	[thread overview]
Message-ID: <e7b36847-fb9e-5cc3-ba2f-b3343a6a1710@gmail.com> (raw)
In-Reply-To: <20221104124800.910588-1-siddhesh@gotplt.org>


On 11/4/22 06:48, Siddhesh Poyarekar wrote:
> Use string length of input to strdup to determine the usable size of the
> resulting object.  Avoid doing the same for strndup since there's a
> chance that the input may be too large, resulting in an unnecessary
> overhead or worse, the input may not be NULL terminated, resulting in a
> crash where there would otherwise have been none.
>
> gcc/ChangeLog:
>
> 	* tree-object-size.cc (todo): New variable.
> 	(object_sizes_execute): Use it.
> 	(strdup_object_size): New function.
> 	(call_object_size): Use it.
>
> gcc/testsuite/ChangeLog:
>
> 	* gcc.dg/builtin-dynamic-object-size-0.c (test_strdup,
> 	test_strndup, test_strdup_min, test_strndup_min): New tests.
> 	(main): Call them.
> 	* gcc.dg/builtin-dynamic-object-size-1.c: Silence overread
> 	warnings.
> 	* gcc.dg/builtin-dynamic-object-size-2.c: Likewise.
> 	* gcc.dg/builtin-dynamic-object-size-3.c: Likewise.
> 	* gcc.dg/builtin-dynamic-object-size-4.c: Likewise.
> 	* gcc.dg/builtin-object-size-1.c: Silence overread warnings.
> 	Declare free, strdup and strndup.
> 	(test11): New test.
> 	(main): Call it.
> 	* gcc.dg/builtin-object-size-2.c: Silence overread warnings.
> 	Declare free, strdup and strndup.
> 	(test9): New test.
> 	(main): Call it.
> 	* gcc.dg/builtin-object-size-3.c: Silence overread warnings.
> 	Declare free, strdup and strndup.
> 	(test11): New test.
> 	(main): Call it.
> 	* gcc.dg/builtin-object-size-4.c: Silence overread warnings.
> 	Declare free, strdup and strndup.
> 	(test9): New test.
> 	(main): Call it.

I'm struggling to see how the SSA updating is correct.  Yes we need to 
update the virtuals due to the introduction of the call to strlen, 
particularly when SRC is not a string constant.  But do we need to do more?

Don't we end up gimplifying the 1 + strlenfn (src) expression? Can that 
possibly create new SSA_NAMEs?  Do those need to be put into SSA form?  
I feel like I'm missing something here...


jeff


  parent reply	other threads:[~2022-11-20 15:42 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-15 19:23 [PATCH] " Siddhesh Poyarekar
2022-08-29 14:16 ` Siddhesh Poyarekar
2022-09-07 19:21   ` Siddhesh Poyarekar
2022-09-15 14:00     ` Siddhesh Poyarekar
2022-09-22 13:02 ` Jakub Jelinek
2022-09-22 15:26   ` Siddhesh Poyarekar
2022-09-23 13:02     ` Jakub Jelinek
2022-11-02 22:30       ` Siddhesh Poyarekar
2022-11-04 12:48 ` [PATCH v2] " Siddhesh Poyarekar
2022-11-04 13:43   ` Prathamesh Kulkarni
2022-11-04 13:47     ` Siddhesh Poyarekar
2022-11-17 19:47   ` Siddhesh Poyarekar
2022-11-20 15:42   ` Jeff Law [this message]
2022-11-21 14:27     ` Siddhesh Poyarekar
2022-11-22 20:43       ` Jeff Law
2022-11-22 23:13         ` Siddhesh Poyarekar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e7b36847-fb9e-5cc3-ba2f-b3343a6a1710@gmail.com \
    --to=jeffreyalaw@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=siddhesh@gotplt.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).