public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Chen Gang <gang.chen@asianux.com>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: linux@horizon.com, Jiri Kosina <jkosina@suse.cz>,
	andriy.shevchenko@linux.intel.com, andrei.emeltchenko@intel.com,
	Andrew Morton <akpm@linux-foundation.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] lib/vsprintf.c: fix the incorrect return value of vsnprintf()
Date: Thu, 18 Jul 2013 14:52:21 +0800	[thread overview]
Message-ID: <51E790A5.3020006@asianux.com> (raw)
In-Reply-To: <20130718064953.GX4165@ZenIV.linux.org.uk>

On 07/18/2013 02:49 PM, Al Viro wrote:
> On Thu, Jul 18, 2013 at 02:28:49PM +0800, Chen Gang wrote:
>> > When "str >= end", necessary to reset 'str' to "end - 1", or the return
>> > value will be larger than the real one, the callers which depend on the
>> > return value, may cause memory overflow.
> You do realize that snprintf(s, 1, "abc") should return 3, not 1?  The
> goal off snprintf() is _not_ just to truncate the output; return value
> tells how much should the buffer had been to fit the whole thing.
> 
> 

It is my fault, thanks.

-- 
Chen Gang

      reply	other threads:[~2013-07-18  6:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-18  6:28 [PATCH] lib/vsprintf.c: fix the incorrect return value of vsnprintf() Chen Gang
2013-07-18  6:42 ` George Spelvin
2013-07-18  6:50   ` Chen Gang
2013-07-18  6:49 ` Al Viro
2013-07-18  6:52   ` Chen Gang [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=51E790A5.3020006@asianux.com \
    --to=gang.chen@asianux.com \
    --cc=akpm@linux-foundation.org \
    --cc=andrei.emeltchenko@intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=jkosina@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@horizon.com \
    --cc=viro@ZenIV.linux.org.uk \
    /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