From: Bruno Haible Date: Fri, 2 Dec 2016 12:52:43 +0000 (+0100) Subject: localcharset: Avoid theoretical buffer overrun. X-Git-Tag: v1.0~6517 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=d1a0a9fba05af9994caaa145045c1e11affc385d;p=gnulib.git localcharset: Avoid theoretical buffer overrun. * lib/localcharset.c (locale_charset) [WINDOWS_NATIVE]: Don't use the return value from setlocale if it would lead to a buffer overrun. --- diff --git a/ChangeLog b/ChangeLog index cdb3cd2451..97fd1708dc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2016-12-02 Bruno Haible + + localcharset: Avoid theoretical buffer overrun. + * lib/localcharset.c (locale_charset) [WINDOWS_NATIVE]: Don't use the + return value from setlocale if it would lead to a buffer overrun. + 2016-12-01 Bruno Haible Relicense some modules under LGPLv2+. diff --git a/lib/localcharset.c b/lib/localcharset.c index ff192f8592..5060aaad6c 100644 --- a/lib/localcharset.c +++ b/lib/localcharset.c @@ -507,7 +507,7 @@ locale_charset (void) current_locale = setlocale (LC_CTYPE, NULL); pdot = strrchr (current_locale, '.'); - if (pdot) + if (pdot && 2 + strlen (pdot + 1) + 1 <= sizeof (buf)) sprintf (buf, "CP%s", pdot + 1); else {