From: Al Viro <viro@ZenIV.linux.org.uk>
To: Chen Gang <gang.chen@asianux.com>
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 07:49:53 +0100 [thread overview]
Message-ID: <20130718064953.GX4165@ZenIV.linux.org.uk> (raw)
In-Reply-To: <51E78B21.50907@asianux.com>
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.
next prev parent reply other threads:[~2013-07-18 6:50 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 [this message]
2013-07-18 6:52 ` Chen Gang
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=20130718064953.GX4165@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=akpm@linux-foundation.org \
--cc=andrei.emeltchenko@intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=gang.chen@asianux.com \
--cc=jkosina@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@horizon.com \
/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