public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Peter Edwards <peadar@arista.com>
To: Andreas Schwab <schwab@suse.de>
Cc: Peter Edwards via Libc-alpha <libc-alpha@sourceware.org>
Subject: Re: [PATCH] elf: Avoid pointer-arithmetic underflow in ldconfig
Date: Mon, 4 Sep 2023 13:32:12 +0100	[thread overview]
Message-ID: <CAO1X7jtwruthdm5ZgTBAeOptpQYT8OHgn7-tTNaRc+AqtA2UGQ@mail.gmail.com> (raw)
In-Reply-To: <mvmmsy22nly.fsf@suse.de>

[-- Attachment #1: Type: text/plain, Size: 760 bytes --]

On Mon, 4 Sept 2023 at 12:18, Andreas Schwab <schwab@suse.de> wrote:

>
> > +               loadoff = (uintptr_t)segment->p_vaddr -
> > +                   (uintptr_t)segment->p_offset;
>
> Shouldn't that use a signed difference, then?  Since loadoff is now
> ptrdiff_t, I would expect the use of ptrdiff_t for the casts.
>
Hi,
For the 32-bit code, we were previously relying on the behaviour of
wrap-around on the unsigned type, this just extends that reliance to a
pointer-sized integer on the 64 bit platform.
I guess intptr_t might be a better option than uintptr_t?  I would think
ptrdiff_t would really only be useful as the difference between two
pointers (and I guess if you want to be pedantic, might not always be the
same as the size of a pointer).

  reply	other threads:[~2023-09-04 12:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-04 10:54 Peter Edwards
2023-09-04 11:18 ` Andreas Schwab
2023-09-04 12:32   ` Peter Edwards [this message]
2023-09-04 14:27     ` Andreas Schwab
2023-09-04 15:34       ` Peter Edwards
2023-09-04 16:26         ` Andreas Schwab
2023-09-04 16:28           ` Peter Edwards

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=CAO1X7jtwruthdm5ZgTBAeOptpQYT8OHgn7-tTNaRc+AqtA2UGQ@mail.gmail.com \
    --to=peadar@arista.com \
    --cc=libc-alpha@sourceware.org \
    --cc=schwab@suse.de \
    /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).