From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 51323 invoked by alias); 24 Aug 2016 17:47:04 -0000 Mailing-List: contact newlib-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-cvs-owner@sourceware.org Received: (qmail 51251 invoked by uid 9078); 24 Aug 2016 17:47:03 -0000 Date: Wed, 24 Aug 2016 17:47:00 -0000 Message-ID: <20160824174703.51248.qmail@sourceware.org> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Corinna Vinschen To: newlib-cvs@sourceware.org Subject: [newlib-cygwin] Avoid crash when calling __localeconv_l with __C_locale X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/master X-Git-Oldrev: 2fd2f308e2504b37a94fa3e3b476ec691ee005c5 X-Git-Newrev: a703d64ad7edac344e4959e8d624ce1d8012678b X-SW-Source: 2016-q3/txt/msg00071.txt.bz2 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=a703d64ad7edac344e4959e8d624ce1d8012678b commit a703d64ad7edac344e4959e8d624ce1d8012678b Author: Corinna Vinschen Date: Wed Aug 24 19:46:55 2016 +0200 Avoid crash when calling __localeconv_l with __C_locale __C_locale is const. Thus, overwriting the lconv values in __localeconv_l will try to write to a R/O region. Given the lconv values in __C_locale are initialized, there's no reason to write them in __localeconv_l at all. Just return &__C_locale.lconv. Signed-off-by: Corinna Vinschen Diff: --- newlib/libc/locale/localeconv.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/newlib/libc/locale/localeconv.c b/newlib/libc/locale/localeconv.c index 1f8816d..165f6f7 100644 --- a/newlib/libc/locale/localeconv.c +++ b/newlib/libc/locale/localeconv.c @@ -6,6 +6,9 @@ struct lconv * __localeconv_l (struct __locale_t *locale) { struct lconv *lconv = &locale->lconv; + if (locale == __get_C_locale ()) + return lconv; + #ifdef __HAVE_LOCALE_INFO__ const struct lc_numeric_T *n = __get_numeric_locale (locale); const struct lc_monetary_T *m = __get_monetary_locale (locale);