public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
To: Joe Simmons-Talbott <josimmon@redhat.com>, libc-alpha@sourceware.org
Subject: Re: [PATCH] resolv/res_query: Add note indicating that alloca usage is safe.
Date: Thu, 14 Sep 2023 14:36:09 -0300	[thread overview]
Message-ID: <8a52dd0c-ae69-cd01-c2c1-01523d7f1543@linaro.org> (raw)
In-Reply-To: <20230914150425.GQ3849957@oak>



On 14/09/23 12:04, Joe Simmons-Talbott wrote:
> Ping.
> 
> On Mon, Aug 28, 2023 at 10:58:25AM -0400, Joe Simmons-Talbott via Libc-alpha wrote:
>> On Mon, Aug 28, 2023 at 10:50:21AM -0300, Adhemerval Zanella Netto wrote:
>>>
>>>
>>> On 05/07/23 15:13, Joe Simmons-Talbott via Libc-alpha wrote:
>>>> The buffer size is small (< 1024) and fixed sized so alloca is safe
>>>> here.
>>>> ---
>>>>  resolv/res_query.c | 1 +
>>>>  1 file changed, 1 insertion(+)
>>>>
>>>> diff --git a/resolv/res_query.c b/resolv/res_query.c
>>>> index 049de91b95..0e0e7be624 100644
>>>> --- a/resolv/res_query.c
>>>> +++ b/resolv/res_query.c
>>>> @@ -117,6 +117,7 @@ __res_context_query (struct resolv_context *ctx, const char *name,
>>>>  	int n, use_malloc = 0;
>>>>  
>>>>  	size_t bufsize = (type == T_QUERY_A_AND_AAAA ? 2 : 1) * QUERYSIZE;
>>>> +	/* alloca is safe here since bufsize < 1024 and fixed sized. */
>>>>  	u_char *buf = alloca (bufsize);
>>>
>>> The bufsize on current Linux build is:
>>>
>>>    size_t bufsize = (type == 439963904 ? 2 : 1) * (12 + 4 + 255 + 1);
>>>
>>> So with upper bound as 544 (2 * (12 + 4 + 255 + 1)).  However, it might
>>> increase to 2 * PACKETSIZE later with malloc.  This is exactly the scenarion
>>> scratch_buffer was created, so maybe we should use it.  Below a complete
>>> untested patch:
>>
>> Thanks for the patch.  I've tested it with 'make check' on
>> x86_64-linux-gnu.  I'm not sure how to handle this and don't feel
>> comfortable submitting it on your behalf or as my own work but am happy
>> to give a Reviewed-by once there's a commit message.

I had forgotten about this, I will send a proper patch.

      reply	other threads:[~2023-09-14 17:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-05 18:13 Joe Simmons-Talbott
2023-08-10 13:46 ` Joe Simmons-Talbott
2023-08-28 13:21   ` Joe Simmons-Talbott
2023-08-28 13:50 ` Adhemerval Zanella Netto
2023-08-28 14:58   ` Joe Simmons-Talbott
2023-09-14 15:04     ` Joe Simmons-Talbott
2023-09-14 17:36       ` Adhemerval Zanella Netto [this message]

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=8a52dd0c-ae69-cd01-c2c1-01523d7f1543@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=josimmon@redhat.com \
    --cc=libc-alpha@sourceware.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).