public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@bigpond.net.au>
To: Zack Weinberg <zack@codesourcery.com>
Cc: binutils@sourceware.org
Subject: Re: gas/hash.c: add interface for looking up non-NUL-terminated strings
Date: Mon, 04 Apr 2005 03:21:00 -0000	[thread overview]
Message-ID: <20050404032129.GH7121@bubble.modra.org> (raw)
In-Reply-To: <871x9ynrx6.fsf@codesourcery.com>

On Tue, Mar 29, 2005 at 12:00:37PM -0800, Zack Weinberg wrote:
> 
> The appended patch adds a new interface to gas/hash.c, hash_find_n,
> with exactly the same semantics as hash_find except that the length of
> the key is passed in as an argument, and the key is not assumed to be
> NUL-terminated.  This is more convenient when parsing an assembly
> instruction: one does not need to write a NUL into the line buffer so
> that hash_find knows where to stop.

Hmm, seems to me that writing a NUL into the line buffer isn't that
onerous.  I'd like to see more justification for this patch,
particularly since we have too many hash table implementations already
in binutils.  At some stage I'd like to move bfd and gas over to use
libiberty's hashtab.c, and another interface difference will make that
task harder.

> -	  if (strcmp (p->string, key) == 0)
> +	  if (p->string[len] == '\0' && strncmp (p->string, key, len) == 0)

Potential access past the end of p->string.  The strncmp must come
first.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

  reply	other threads:[~2005-04-04  3:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-30 10:49 Zack Weinberg
2005-04-04  3:21 ` Alan Modra [this message]
2005-04-04  5:33   ` Zack Weinberg

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=20050404032129.GH7121@bubble.modra.org \
    --to=amodra@bigpond.net.au \
    --cc=binutils@sourceware.org \
    --cc=zack@codesourcery.com \
    /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).