From: "Trần Ngọc Quân" <vnwildman@gmail.com>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: git@vger.kernel.org, Jonathan Niedier <jrnieder@gmail.com>,
schwab@linux-m68k.org, tboegi@web.de
Subject: Re: [PATCH v3] gettext.c: detect the vsnprintf bug at runtime
Date: Mon, 02 Dec 2013 07:31:29 +0700 [thread overview]
Message-ID: <529BD4E1.8040408@gmail.com> (raw)
In-Reply-To: <1385865938-16392-1-git-send-email-pclouds@gmail.com>
On 01/12/2013 09:45, Nguyễn Thái Ngọc Duy wrote:
> Bug 6530 [1] in glibc causes "git show v0.99.6~1" to fail with error
> "your vsnprintf is broken". The workaround avoids that, but it
> corrupts system error messages in non-C locales.
>
> The bug has been fixed since 2.17. We could know running glibc version
> with gnu_get_libc_version(). But version is not a sure way to detect
> the bug because downstream may back port the fix to older versions. Do
> a runtime test that immitates the call flow that leads to "your
> vsnprintf is broken". Only enable the workaround if the test fails.
>
> Tested on Gentoo Linux, glibc 2.16.0 and 2.17, amd64.
>
> [1] http://sourceware.org/bugzilla/show_bug.cgi?id=6530
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
> v3 goes with runtime test instead of version check.
>
> gettext.c | 19 +++++++++++++++----
> 1 file changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/gettext.c b/gettext.c
> index 71e9545..eed7c7f 100644
> --- a/gettext.c
> +++ b/gettext.c
> @@ -29,6 +29,17 @@ int use_gettext_poison(void)
> #endif
>
> #ifndef NO_GETTEXT
> +static int test_vsnprintf(const char *fmt, ...)
> +{
> + char buf[26];
> + int ret;
> + va_list ap;
> + va_start(ap, fmt);
> + ret = vsnprintf(buf, sizeof(buf), fmt, ap);
> + va_end(ap);
> + return ret;
> +}
> +
this function alway run each time we run git commad while libc is
static. It is waste.
> + /* the string is taken from v0.99.6~1 */
> + if (test_vsnprintf("%.*s", 13, "David_K\345gedal") < 0)
> + setlocale(LC_CTYPE, "C");
> }
>
> void git_setup_gettext(void)
I suggest use C preprocessor instead. The person who complete git (make debian, rpm etc. package) decide enable it or not (disable by default). Most of people use git from distribution instead of complete it from source.
#ifndef VSNPRINTF_OK
setlocale(LC_CTYPE, "C");
#endif
--
Trần Ngọc Quân.
next prev parent reply other threads:[~2013-12-02 0:32 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-30 1:51 [PATCH] gettext.c: only work around the vsnprintf bug on glibc < 2.17 Nguyễn Thái Ngọc Duy
2013-11-30 9:51 ` Andreas Schwab
2013-11-30 12:01 ` [PATCH v2] " Nguyễn Thái Ngọc Duy
2013-11-30 23:01 ` Torsten Bögershausen
2013-11-30 23:06 ` Torsten Bögershausen
2013-12-01 1:33 ` Duy Nguyen
2013-12-01 2:45 ` [PATCH v3] gettext.c: detect the vsnprintf bug at runtime Nguyễn Thái Ngọc Duy
2013-12-02 0:31 ` Trần Ngọc Quân [this message]
2013-12-02 5:57 ` Duy Nguyen
2013-12-02 7:40 ` Trần Ngọc Quân
2013-12-02 8:49 ` Trần Ngọc Quân
2013-12-02 9:00 ` Duy Nguyen
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=529BD4E1.8040408@gmail.com \
--to=vnwildman@gmail.com \
--cc=git@vger.kernel.org \
--cc=jrnieder@gmail.com \
--cc=pclouds@gmail.com \
--cc=schwab@linux-m68k.org \
--cc=tboegi@web.de \
/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).