public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: DJ Delorie <dj@redhat.com>
To: "Леонид Юрьев (Leonid Yuriev)\\r\
" <leo@yuriev.ru>
Cc: libc-alpha@sourceware.org, drepper.fsp@gmail.com, leo@yuriev.ru
Subject: Re: [PATCH] gmon: Fix allocated buffer overflow (bug 2944)
Date: Tue, 07 Feb 2023 17:12:25 -0500	[thread overview]
Message-ID: <xn4jrxcegm.fsf@greed.delorie.com> (raw)
In-Reply-To: <20230204114138.5436-1-leo@yuriev.ru>

›µ¾½¸´
®€Œµ² (Leonid Yuriev) <leo@yuriev.ru>
writes:
>    p->lowpc = ROUNDDOWN(lowpc, HISTFRACTION * sizeof(HISTCOUNTER));
>    p->highpc = ROUNDUP(highpc, HISTFRACTION * sizeof(HISTCOUNTER));
>    p->textsize = p->highpc - p->lowpc;
> -  p->kcountsize = ROUNDUP(p->textsize / HISTFRACTION, sizeof(*p->froms));
> +  p->kcountsize = ROUNDUP(p->textsize / HISTFRACTION, sizeof(*p->kcount));

I think the purpose here isn't to make sure the last entry fits, as that
it handled when lowpc and highpc are rounded.  I think the purpose here
is to make sure that the *next* portion of the buffer (p->froms) is
suitably aligned for its type.

> -  p->fromssize = p->textsize / HASHFRACTION;
> +  p->fromssize = ROUNDUP(p->textsize / HASHFRACTION, sizeof(*p->froms));

This part looks OK to me.


  parent reply	other threads:[~2023-02-07 22:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-04 11:41 Леонид Юрьев (Leonid Yuriev)
2023-02-07 14:22 ` Carlos O'Donell
2023-02-07 15:06 ` Siddhesh Poyarekar
2023-02-07 22:12 ` DJ Delorie [this message]
2023-02-14  5:59   ` [PATCH v2] " DJ Delorie
2023-02-21 21:10     ` Carlos O'Donell

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=xn4jrxcegm.fsf@greed.delorie.com \
    --to=dj@redhat.com \
    --cc=drepper.fsp@gmail.com \
    --cc=leo@yuriev.ru \
    --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).