git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] gettext.c: only work around the vsnprintf bug on glibc < 2.17

From
Torsten Bögershausen <tboegi@web.de>
Date
Nov 30, 2013, 23:01 UTC
Message-ID
<529A6E48.4050001@web.de>
In-Reply-To
<1385812884-23776-1-git-send-email-pclouds@gmail.com>
On 2013-11-30 13.01, Nguyễn Thái Ngọc Duy wrote:
> Bug 6530 [1] causes "git show v0.99.6~1" to fail with error "your
causes or caused (as we have a work around?)
> vsnprintf is broken". The workaround avoids that, but it corrupts
> system error messages in non-C locales.
[snip]
> The bug in glibc has been fixed since 2.17. If git is built with glibc, it can
                ^^^^^^ (Should we name glibc ?)
[snip]
> -	setlocale(LC_MESSAGES, "");
> -	init_gettext_charset("git");
> +	setlocale(vsnprintf_broken ? LC_MESSAGES : LC_ALL, "");
1) One thing I don't understand: Why do we need to set LC_ALL ?
The old patch didn't do it, or what do I miss ?
See https://wiki.debian.org/Locale :
Using LC_ALL is strongly discouraged as it overrides everything. Please use it only when testing and never set it in a startup file.
2) I stole the code partly from here:
   http://sourceware.org/bugzilla/show_bug.cgi?id=6530
----------------------
#include <stdio.h>
#include <locale.h>
#include <gnu/libc-version.h>
#define STR "²éľÂíɱ²¡¶¾£¬ÖܺèµtÄúµÄ360²»×¨Òµ£¡"
int main(void) {
        char buf[200];
        setlocale(LC_ALL, "");
                                printf("gnu_glibc_version()=%s\n",  gnu_get_libc_version());
        printf("ret(snprintf)=%d\n", snprintf(buf, 150, "%.50s", STR));
        return 0;
}

---------------------- Then I run it on different machines:

gnu_glibc_version()=2.11.3 /* Ubuntu 10.4, no updates */ gnu_glibc_version()=2.11.3 /* Debian Squeze ?*/ gnu_glibc_version()=2.13 /* Debian Wheezy */ ret(snprintf)=50 /* All the 3 above */ ------------- So could it be that libc is patched in Debian/Ubuntu, and we can do a runtime check (rather than looking at the version number), similar to the code above ? ------------

3) The patch didn't break anything here (Debian, Mac OS).
4) Could it be good to have a test case ? Is t0204 good for inspiration ?
5) I can do more testing if needed.
/Torsten
Previous: Nguyễn Thái Ngọc DuyNext: Torsten Bögershausen
Message 4 of 12 in “gettext.c: only work around the vsnprintf bug on glibc < 2.17”
  1. gettext.c: only work around the vsnprintf bug on glibc < 2.17Nguyễn Thái Ngọc Duy, Nov 30, 2013
  2. Andreas SchwabNov 30, 2013
  3. gettext.c: only work around the vsnprintf bug on glibc < 2.17Nguyễn Thái Ngọc Duy, Nov 30, 2013
  4. Torsten BögershausenNov 30, 2013
  5. Torsten BögershausenNov 30, 2013
  6. Duy NguyenDec 1, 2013
  7. gettext.c: detect the vsnprintf bug at runtimeNguyễn Thái Ngọc Duy, Dec 1, 2013
  8. Trần Ngọc QuânDec 2, 2013
  9. Duy NguyenDec 2, 2013
  10. Trần Ngọc QuânDec 2, 2013
  11. Trần Ngọc QuânDec 2, 2013
  12. Duy NguyenDec 2, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.