[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <75c8f066c3aa2e20db2e1554a4d28c20b2952724.camel@perches.com>
Date: Fri, 14 Jun 2019 19:58:23 -0700
From: Joe Perches <joe@...ches.com>
To: "Yan, Zheng" <ukernel@...il.com>, Jeff Layton <jlayton@...nel.org>
Cc: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
ceph-devel <ceph-devel@...r.kernel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Ilya Dryomov <idryomov@...il.com>, Zheng Yan <zyan@...hat.com>,
Sage Weil <sage@...hat.com>, agruenba@...hat.com
Subject: Re: [PATCH 1/3] lib/vsprintf: add snprintf_noterm
On Sat, 2019-06-15 at 10:41 +0800, Yan, Zheng wrote:
> On Fri, Jun 14, 2019 at 9:48 PM Jeff Layton <jlayton@...nel.org> wrote:
> > The getxattr interface returns a length after filling out the value
> > buffer, and the convention with xattrs is to not NULL terminate string
> > data.
> >
> > CephFS implements some virtual xattrs by using snprintf to fill the
> > buffer, but that always NULL terminates the string. If userland sends
> > down a buffer that is just the right length to hold the text without
> > termination then we end up truncating the value.
> >
> > Factor the formatting piece of vsnprintf into a separate helper
> > function, and have vsnprintf call that and then do the NULL termination
> > afterward. Then add a snprintf_noterm function that calls the new helper
> > to populate the string but skips the termination.
Is this function really necessary enough to add
the additional stack use to the generic case?
Why not add have this function call vsnprintf
and then terminate the string separately?
Powered by blists - more mailing lists