Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1374316

Re: [PATCH 2/3] orangefs: strncpy -> strlcpy

From martin@omnibond.com
Newsgroups linux.kernel
Subject Re: [PATCH 2/3] orangefs: strncpy -> strlcpy
Date 2016-04-08 17:40 +0200
Message-ID <rlGFQ-60n-19@gated-at.bofh.it> (permalink)
References <rkjii-dT-11@gated-at.bofh.it> <rkjik-dT-49@gated-at.bofh.it> <rln0u-87S-31@gated-at.bofh.it> <rlo6e-o4-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


> On Thu, Apr 7, 2016 at 2:39 PM, Andy Shevchenko
> <andy.shevchenko@gmail.com> wrote:
> > On Mon, Apr 4, 2016 at 11:26 PM, Martin Brandenburg <martin@omnibond.com> wrote:
> >> From: Martin Brandenburg <martin@omnibond.com>
> >>
> >> Almost everywhere we use strncpy we should use strlcpy. This affects
> >> path names (d_name mostly), symlink targets, and server names.
> >>
> >> Leave debugfs code as is for now, though it could use a review as well.
> >>
> >
> > |Why not strscpy() as most robust one?

Mostly because I hadn't heard about strscpy.

On Thu, 7 Apr 2016, Mike Marshall wrote:

> It looks like strscpy went in last October... there are
> no users of it yet. I was just about to send in a pull request
> that includes Martin's strncpy->strlcpy patch when I saw
> Andy's comment.
> 
> Linus said when he pulled strscpy:
> 
> > So I'm pulling the strscpy() support because it *is* a better interface.
> > But I will refuse to pull mindless conversion patches.  Use this in
> > places where it makes sense, but don't do trivial patches to fix things
> > that aren't actually known to be broken.
> 
> Maybe it makes sense for our strncpy->strlcpy patch to be a strscpy
> patch instead? Maybe our strncpy->strlcpy patch is itself a
> "mindless conversion patch"? (I don't think so)...

There is something broken! If the client-core sends in a
string with no NUL terminator, we would blindly copy it
into the d_name with strncpy.

> 
> I'll wait until tomorrow, and then send my pull request as it is, unless
> everyone chimes in and says "use strscpy!"...
> 
> -Mike

After looking over strscpy I don't see a compelling
reason not to go ahead and use it while we're fixing up
this code.

-- Martin

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 1/3] orangefs: clean up truncate ctime and mtime setting Martin Brandenburg <martin@omnibond.com> - 2016-04-04 22:30 +0200
  [PATCH 2/3] orangefs: strncpy -> strlcpy Martin Brandenburg <martin@omnibond.com> - 2016-04-04 22:30 +0200
    Re: [PATCH 2/3] orangefs: strncpy -> strlcpy Andy Shevchenko <andy.shevchenko@gmail.com> - 2016-04-07 20:40 +0200
      Re: [PATCH 2/3] orangefs: strncpy -> strlcpy Mike Marshall <hubcap@omnibond.com> - 2016-04-07 21:50 +0200
        Re: [PATCH 2/3] orangefs: strncpy -> strlcpy martin@omnibond.com - 2016-04-08 17:40 +0200
          Re: [PATCH 2/3] orangefs: strncpy -> strlcpy Andy Shevchenko <andy.shevchenko@gmail.com> - 2016-04-08 18:10 +0200
            Re: [PATCH 2/3] orangefs: strncpy -> strlcpy martin@omnibond.com - 2016-04-08 19:20 +0200
              [PATCH] orangefs: strncpy -> strscpy Martin Brandenburg <martin@omnibond.com> - 2016-04-08 19:40 +0200
  [PATCH 3/3] orangefs: remove unused variable Martin Brandenburg <martin@omnibond.com> - 2016-04-04 22:30 +0200

csiph-web