From: Alan Modra <amodra@bigpond.net.au>
To: Mark Kettenis <kettenis@chello.nl>
Cc: binutils@sources.redhat.com, gdb-patches@sources.redhat.com
Subject: Re: [RFA/PATCH] Fix recognition of NT_PRXFREG notes
Date: Thu, 04 Jul 2002 20:05:00 -0000 [thread overview]
Message-ID: <20020705013029.GC30362@bubble.sa.bigpond.net.au> (raw)
In-Reply-To: <200207041503.g64F3Mj08511@elgar.kettenis.dyndns.org>
On Thu, Jul 04, 2002 at 05:03:22PM +0200, Mark Kettenis wrote:
> Index: elf.c
> ===================================================================
> RCS file: /cvs/src/src/bfd/elf.c,v
> retrieving revision 1.152
> diff -u -p -r1.152 elf.c
> --- elf.c 4 Jul 2002 13:26:30 -0000 1.152
> +++ elf.c 4 Jul 2002 14:54:36 -0000
> @@ -6718,8 +6718,7 @@ elfcore_grok_note (abfd, note)
> #endif
>
> case NT_PRXFPREG: /* Linux SSE extension */
> - if (note->namesz == 5
> - && ! strcmp (note->namedata, "LINUX"))
> + if (strncmp (note->namedata, "LINUX", 5) == 0)
> return elfcore_grok_prxfpreg (abfd, note);
> else
> return true;
Don't the alignment rules require that the name be padded out to a
multiple of 4 chars? (or 8 on 64 bit ELF files). So you should have
'L','I','N','U','X','\0','\0','\0' and thus can use strcmp. Also,
it's a good idea to check namesz before accessing namedata. I'm
sure I can make your strncmp segfault by carefully crafting a
non-compliant note.
Hmm, on re-reading the ELF standard, I see the pad char isn't
specified. :-( But obviously the original strcmp worked, so the
pad from the kernel is zero. Please use
if (note->namesz >= 5
&& strcmp (note->namedata, "LINUX") == 0)
and commit the patch. Thanks.
--
Alan Modra
IBM OzLabs - Linux Technology Centre
next prev parent reply other threads:[~2002-07-05 1:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-07-04 8:15 Mark Kettenis
2002-07-04 20:05 ` Alan Modra [this message]
2002-07-05 7:45 ` Nick Clifton
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=20020705013029.GC30362@bubble.sa.bigpond.net.au \
--to=amodra@bigpond.net.au \
--cc=binutils@sources.redhat.com \
--cc=gdb-patches@sources.redhat.com \
--cc=kettenis@chello.nl \
/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