linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matt Mackall <mpm@selenic.com>
To: Valdis.Kletnieks@vt.edu
Cc: linux-kernel@vger.kernel.org
Subject: Re: Resend [PATCH] Make KOBJ_NAME_LEN match BUS_ID_SIZE
Date: Sun, 25 May 2003 18:42:02 -0500	[thread overview]
Message-ID: <20030525234202.GO23715@waste.org> (raw)
In-Reply-To: <200305251813.h4PID2oH021773@turing-police.cc.vt.edu>

On Sun, May 25, 2003 at 02:13:02PM -0400, Valdis.Kletnieks@vt.edu wrote:
> On Sun, 25 May 2003 10:51:02 CDT, Matt Mackall said:
> 
> > The return value here isn't particularly useful. The OpenBSD
> > strlcpy/strlcat variant tell you how big the result should have been
> > so that you can realloc if need be.
> 
> A quick grep of the current source tree seems to indicate that there aren't
> any uses of 'strncpy' that actually save or check the return value.
> 
> As such, actually *using*  the return value would make for a job for the
> kernel janitors, to actually do something useful at all 650 or so uses.

The kernel, fortunately, isn't Perl or the like and really isn't
interested in strings outside the context of things like pathnames,
which realistically have to have finite limits. So while there
probably aren't a lot of uses for a return val, for the places where
there are, min(bufsize, optimalsize) is going to be less useful than
just optimalsize as you already know bufsize.
 
> Given that the kernel probably *shouldn't* be trying to strlcpy() into
> a destination that it won't fit, it may be more useful to do a BUG_ON()
> or similar (feel free to use a 'goto too_long;' if you prefer ;)

Outside of pathnames type things, where there's a well-defined return
code (ENAMETOOLONG), we probably end up not caring overmuch about
truncation..

-- 
Matt Mackall : http://www.selenic.com : of or relating to the moon

  reply	other threads:[~2003-05-25 23:28 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-13  6:26 [PATCH] Make KOBJ_NAME_LEN match BUS_ID_SIZE Ben Collins
2003-05-13  7:10 ` Christoph Hellwig
2003-05-13  7:14   ` Ben Collins
2003-05-13 15:08     ` Patrick Mochel
2003-05-16  0:20       ` Resend " Ben Collins
2003-05-16 18:43         ` Felipe Alfaro Solana
2003-05-25  0:07         ` Ben Collins
2003-05-25  3:52           ` Linus Torvalds
2003-05-25  3:10             ` Ben Collins
2003-05-25 12:03             ` Adam Sampson
2003-05-25 17:10               ` Linus Torvalds
2003-05-25 16:40                 ` Ben Collins
2003-05-25 15:51             ` Matt Mackall
2003-05-25 17:25               ` Riley Williams
2003-05-25 18:13               ` Valdis.Kletnieks
2003-05-25 23:42                 ` Matt Mackall [this message]
2003-05-25 16:41             ` Ben Collins
2003-07-11  9:50             ` Rogier Wolff
2003-05-25  8:02           ` Russell King
2003-05-25  9:21 René Scharfe
2003-05-25 12:05 ` Christoph Hellwig
2003-05-25 17:24 ` Edgar Toernig
2003-05-25 19:05   ` René Scharfe
2003-05-25 18:16     ` Ben Collins
2003-05-25 20:11       ` René Scharfe
2003-05-25 19:01     ` Valdis.Kletnieks
2003-05-25 19:31       ` René Scharfe
2003-05-26  1:13     ` Linus Torvalds

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=20030525234202.GO23715@waste.org \
    --to=mpm@selenic.com \
    --cc=Valdis.Kletnieks@vt.edu \
    --cc=linux-kernel@vger.kernel.org \
    /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 NNTP newsgroup(s).