All of lore.kernel.org
 help / color / mirror / Atom feed
From: Valerie Aurora Henson <vaurora@redhat.com>
To: Ian Kent <raven@themaw.net>
Cc: autofs@linux.kernel.org
Subject: Re: [PATCH 3/4] Easy alloca() replacements
Date: Fri, 16 Jan 2009 17:11:19 -0500	[thread overview]
Message-ID: <20090116221119.GH6607@shell> (raw)
In-Reply-To: <1231557516.3047.61.camel@zeus.themaw.net>

On Sat, Jan 10, 2009 at 12:18:36PM +0900, Ian Kent wrote:
> On Fri, 2009-01-09 at 13:47 -0500, Valerie Aurora Henson wrote:
> 
> Just a first pass reading but noticed ....
> 
> > diff --git a/lib/cache.c b/lib/cache.c
> > index 36b8294..bc2c722 100644
> > --- a/lib/cache.c
> > +++ b/lib/cache.c
> > @@ -484,27 +484,19 @@ struct mapent *cache_lookup_offset(const char *prefix, const char *offset, int s
> >  {
> >  	struct list_head *p;
> >  	struct mapent *this;
> > -	int plen = strlen(prefix);
> > -	char *o_key;
> > +	char o_key[KEY_MAX_LEN];
> 
> I know this looks right but I think it will end up being a problem
> latter. I know there are places in the map lookup libraries that
> restrict these to KEY_MAX_LEN, which is needed for indirect map keys,
> but direct map keys really shouldn't have this restriction as they
> should be able to be as long as PATH_MAX but that brings the issue of
> needing to audit and adjust the maximum parse buffer as well. So we will
> need to get around to that at some point as well.

It certainly won't hurt to make this PATH_MAX - I'll do that unless I
hear otherwise.

> >  
> >  	/* root offset duplicates "/" */
> > -	if (plen > 1) {
> > -		o_key = alloca(plen + strlen(offset) + 1);
> > -		strcpy(o_key, prefix);
> > -		strcat(o_key, offset);
> > -	} else {
> > -		o_key = alloca(strlen(offset) + 1);
> > -		strcpy(o_key, offset);
> > -	}
> > +	if (snprintf(o_key, sizeof(o_key), "%s%s", prefix, offset) >
> > +	    sizeof(o_key))
> > +		return NULL;
> 
> Looks like this will set o_key to "//..." for strlen(prefix) == 1.

I'll fix it, thanks

-VAL

  reply	other threads:[~2009-01-16 22:11 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-09 18:46 [PATCH 0/4] autofs scaling and cleanup patches Valerie Aurora Henson
2009-01-09 18:47 ` [PATCH 1/4] Make hash table scale to thousands of entries Valerie Aurora Henson
2009-01-09 18:47   ` [PATCH 2/4] Make MAX_ERR_BUF and PARSE_MAX_BUF use easier to audit Valerie Aurora Henson
2009-01-09 18:47     ` [PATCH 3/4] Easy alloca() replacements Valerie Aurora Henson
2009-01-09 18:47       ` [PATCH 4/4] Replace <linux/string.h> with <string.h> Valerie Aurora Henson
2009-01-12  5:59         ` Ian Kent
2009-01-09 20:48       ` [PATCH 3/4] Easy alloca() replacements Valerie Aurora Henson
2009-01-10  3:18       ` Ian Kent
2009-01-16 22:11         ` Valerie Aurora Henson [this message]
2009-01-09 19:00     ` [PATCH 2/4] Make MAX_ERR_BUF and PARSE_MAX_BUF use easier to audit Jeff Moyer
2009-01-09 19:54       ` Valerie Aurora Henson
2009-01-09 19:17   ` [PATCH 1/4] Make hash table scale to thousands of entries Jeff Moyer
2009-01-09 19:51     ` Valerie Aurora Henson
2009-01-10  1:19       ` Paul Wankadia
2009-01-11 16:42         ` Ian Kent
2009-01-11 23:25           ` Paul Wankadia
2009-01-12  1:13             ` Ian Kent
2009-01-12  1:19             ` Ian Kent
2009-01-12  2:10               ` Paul Wankadia
2009-01-12  4:02               ` Ian Kent
2009-01-12  4:58                 ` Ian Kent
2009-01-13  1:52                   ` Paul Wankadia
2009-01-13  2:24                     ` Ian Kent
2009-01-13  4:15                       ` Ian Kent
2009-01-13  5:07                         ` Paul Wankadia
2009-01-13  5:19                           ` Ian Kent
2009-01-14  3:43                             ` Paul Wankadia
2009-01-14  8:47                               ` Ian Kent
2009-01-14 10:52                                 ` Paul Wankadia
2009-01-14 13:17                                   ` Ian Kent
2009-01-14 14:20                                     ` Paul Wankadia
2009-01-15  1:41                                       ` Ian Kent
2009-01-15 15:04                                         ` Jeff Moyer
2009-01-15 15:16                                           ` Ian Kent
2009-01-15 20:33                                             ` Paul Wankadia
2009-01-15 20:41                                               ` Jeff Moyer
2009-01-15 20:57                                                 ` Paul Wankadia
2009-01-16  0:27                                                   ` Ian Kent
2009-01-16  0:40                                                     ` Ian Kent
2009-01-16  1:43                                                       ` Ian Kent
2009-01-16  3:59                                                         ` Paul Wankadia
2009-01-16  4:21                                                           ` Ian Kent
2009-01-16  5:05                                                             ` Ian Kent
2009-01-16  6:04                                                             ` Paul Wankadia
2009-01-16  6:24                                                               ` Ian Kent
2009-01-16  6:39                                                                 ` Ian Kent
2009-01-17 17:11                                                                   ` Paul Wankadia
2009-01-18  3:26                                                                     ` Ian Kent
2009-01-19  1:28                                                                       ` Paul Wankadia
2009-01-19  2:03                                                                         ` Ian Kent
2009-01-19  5:23                                                                           ` Paul Wankadia
2009-01-19  6:13                                                                             ` Ian Kent
2009-01-16  5:23                                                         ` Ian Kent
2009-01-16  0:33                                             ` Ian Kent
2009-01-10 14:45       ` Ian Kent
2009-01-10  2:07     ` Ian Kent
2009-01-10  3:29   ` Ian Kent
2009-01-10  3:57     ` Ian Kent
2009-01-13  5:51   ` Ian Kent
2009-01-14  3:58     ` Paul Wankadia
2009-01-14  8:48       ` Ian Kent
2009-01-15  2:47         ` Valerie Aurora Henson
2009-01-15  3:02           ` Ian Kent
2009-01-16 21:39             ` Valerie Aurora Henson
2009-01-15  5:06           ` Paul Wankadia
2009-01-15  4:42       ` Ian Kent

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=20090116221119.GH6607@shell \
    --to=vaurora@redhat.com \
    --cc=autofs@linux.kernel.org \
    --cc=raven@themaw.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.