Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 9 Jul 2013 10:11:00 -0700
From:      Jeremy Chadwick <jdc@koitsu.org>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        freebsd-fs@freebsd.org
Subject:   Re: Compatibility options for mount(8)
Message-ID:  <20130709171100.GA10423@icarus.home.lan>
In-Reply-To: <20130709165658.GO91021@kib.kiev.ua>
References:  <CAOfDtXM_KJeLLUcsFA0EZOC8ZgSjKiLKuGeeNPQKCcZwcaJbCQ@mail.gmail.com> <20130702000732.GA72587@icarus.home.lan> <CAOfDtXNxT%2BhnS8n%2BOY6a7n=6UiwgDJo6M3GZx48JgskRKoY=gg@mail.gmail.com> <20130709150129.GA8289@icarus.home.lan> <20130709165658.GO91021@kib.kiev.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Jul 09, 2013 at 07:56:59PM +0300, Konstantin Belousov wrote:
> On Tue, Jul 09, 2013 at 08:01:29AM -0700, Jeremy Chadwick wrote:
> > On Tue, Jul 09, 2013 at 04:47:46PM +0200, Robert Millan wrote:
> > > > 2. Please use strncmp().  I know other parts of the same code use strcmp()
> > > > and those should really be improved at some other time, but while you're
> > > > already there you might as well use strncmp() (you'll see others have
> > > > done the same), i.e.:
> > > >
> > > >                         } else if (strncmp(p, "remount", 7) == 0) {
> > > 
> > > What is the rationale behind this?
> > 
> > Primarily security and stability.  I won't get into a discussion about
> > this as it'll just bikeshed, particularly when there's an almost
> > indefinite amount of information online about the dangers of strcmp(3).
> 
> Robert, please ignore this.  The person does not know what he talks about.
> 
> The use of strncmp() is plain wrong. E.g., it would match  "remount1"
> as well as any longer option starting with "remount".  Original patch
> is fine.

kib@, thanks for correcting me -- you're absolutely right in this case.

I was looking at the mountprog/userquota=/groupquota= examples and did
not notice the use of strsep(3) within the while().  So yes, use of
strncmp(3) in this case is completely wrong.  My apologies.

-- 
| Jeremy Chadwick                                   jdc@koitsu.org |
| UNIX Systems Administrator                http://jdc.koitsu.org/ |
| Making life hard for others since 1977.             PGP 4BD6C0CB |




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130709171100.GA10423>