All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Kent <raven@themaw.net>
To: Jeff Moyer <jmoyer@redhat.com>
Cc: autofs mailing list <autofs@linux.kernel.org>
Subject: Re: [PATCH] Possible buffer overflow
Date: Fri, 01 Dec 2006 10:01:50 +0800	[thread overview]
Message-ID: <1164938510.3404.6.camel@localhost> (raw)
In-Reply-To: <x49mz68u3qu.fsf@segfault.boston.devel.redhat.com>

On Thu, 2006-11-30 at 14:35 -0500, Jeff Moyer wrote:
> ==> On Thu, 30 Nov 2006 18:06:43 +0100, Matthias Koenig <mkoenig@suse.de> said:
> 
> Matthias> Hi,
> Matthias> There seems to be a possible buffer overflow in modules/mount_afs.c.
> Matthias> strncat(dest, src, n) uses at most n chars from src. n is not the
> Matthias> size of dest. Patch below.
> 
> The fix seems correct to me.  Have you actually seen a problem in the
> wild?  I wonder why the dest string is twice the maximum path length;
> that doesn't make a whole lot of sense.  Perhaps we should fix that
> while we're in here.

Yes, that array does seem to be excessive.
I was thinking that it would be better to calculate the length, check it
and then do the copy.

> 
> -Jeff
> 
> > --- modules/mount_afs.c
> > +++ modules/mount_afs.c
> > @@ -36,8 +36,8 @@
> >  	char dest[PATH_MAX * 2];
> 
> >  	strcpy(dest, root);	/* Convert the name to a mount point. */
> > -	strncat(dest, "/", sizeof(dest));
> > -	strncat(dest, name, sizeof(dest));
> > +	strncat(dest, "/", sizeof(dest)-strlen(dest)-1);
> > +	strncat(dest, name, sizeof(dest)-strlen(dest)-1);
> 
> >  	/* remove trailing slash (http://bugs.debian.org/141775) */
> >  	if (dest[strlen(dest)-1] == '/')
> 
> _______________________________________________
> autofs mailing list
> autofs@linux.kernel.org
> http://linux.kernel.org/mailman/listinfo/autofs

      reply	other threads:[~2006-12-01  2:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-30 17:06 [PATCH] Possible buffer overflow Matthias Koenig
2006-11-30 19:35 ` Jeff Moyer
2006-12-01  2:01   ` Ian Kent [this message]

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=1164938510.3404.6.camel@localhost \
    --to=raven@themaw.net \
    --cc=autofs@linux.kernel.org \
    --cc=jmoyer@redhat.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 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.