All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jerome de Vivie <jerome.devivie@free.fr>
To: Bryan Henderson <hbryan@us.ibm.com>
Cc: Matthew Wilcox <willy@debian.org>, Jan Hudec <bulb@ucw.cz>,
	linux-fsdevel@vger.kernel.org
Subject: Re: Does struct qstr->name should be terminated ?
Date: Thu, 25 Mar 2004 01:09:04 +0100	[thread overview]
Message-ID: <40622320.8000904@free.fr> (raw)
In-Reply-To: <OFA3D1854E.0541BF33-ON87256E61.005DFCD3-88256E61.005E1186@us.ibm.com>

Bryan Henderson wrote:
>>>I'd think that it's treated as a nomral string in quite a few places, 
> 
> so
> 
>>>it needs to be NUL terminated. (But not searched the sources.)
>>
>>Why not?  It isn't hard to find.
>>
>>fs/dcache.c:703:        str[name->len] = 0;
> 
> 
> That's technically an area where it's treated like a normal string, but 

I thougth that qstr->name was not treated as a normal string and has
been design to speedup d_compare test with strncmp instead of strcmp.
That's why i never bother with the null termination caracter.

> not really relevant to the question (which is "what if I don't 
> nul-terminate the thing"?  Do you have an example handy of a strcmp() or 
> such that would fail if the NUL terminator were not there?

In  yourfs->d_lookup, you can reallocate qstr and pad d_name with random
caracters. After that, unexpected behavior could happen after a mv(1):
the VFS could increment qstr->len. The result is one more caracter for
some entries after a ls(1).


      reply	other threads:[~2004-03-25  0:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-23 10:56 Does struct qstr->name should be terminated ? Jerome de Vivie
2004-03-24  9:09 ` Jan Hudec
2004-03-24 13:05   ` Matthew Wilcox
2004-03-24 17:09     ` Bryan Henderson
2004-03-25  0:09       ` Jerome de Vivie [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=40622320.8000904@free.fr \
    --to=jerome.devivie@free.fr \
    --cc=bulb@ucw.cz \
    --cc=hbryan@us.ibm.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=willy@debian.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 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.