| Message ID | 20260824080300.805-1-takashi.yano@nifty.ne.jp |
|---|---|
| State | New |
| Headers |
Return-Path: <newlib-bounces~patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CBDAA4BA23FB for <patchwork@sourceware.org>; Mon, 24 Aug 2026 08:03:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CBDAA4BA23FB Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=nifty.ne.jp header.i=@nifty.ne.jp header.a=rsa-sha256 header.s=default-1th84yt82rvi header.b=TOgTmTQK X-Original-To: newlib@sourceware.org Delivered-To: newlib@sourceware.org Received: from mta-snd-e07.mail.nifty.com (mta-snd-e07.mail.nifty.com [106.153.226.39]) by sourceware.org (Postfix) with ESMTPS id 81DB34BA2E2C for <newlib@sourceware.org>; Mon, 24 Aug 2026 08:03:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 81DB34BA2E2C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=nifty.ne.jp Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nifty.ne.jp ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 81DB34BA2E2C Authentication-Results: sourceware.org; arc=none smtp.remote-ip=106.153.226.39 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1787558594; cv=none; b=IlI4VPDuYSRbVCbY/Hh1+JhPOJMMYXV0XI8fdDzOsPG3h6HixcE4eplb+pBAHyJeKJwpmOPuWsxxYWejFrQvC+kZ8qtR/RkQaXvOr4snHnCrMmSuryZfYOQX/03VTXv13vm++2Ag8rplqeCLiy3BvwIfNCUKEtW5vJmiNXe2MC8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1787558594; c=relaxed/simple; bh=14v3J4RJdH2VOGM6ywhUi9fOY+nM4Da9g0oewnCc9yg=; h=From:To:Subject:Date:Message-ID:MIME-Version:DKIM-Signature; b=PuFKlxdAuGS0AL9ev1BJD7QUBqQREgZeu4DSXD19De2T3jgaHykYE1ueYXA72coosHhWzwZFiVam7yPmkmcIPr2Ly+Oz5RozKkSQFRlhzrIPM964t3pgwiAs0UYqyH3+/Hocfv/APfSXZrMxs/QCsmhOHvHoQiOQMcvuZO+TEcY= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=nifty.ne.jp header.i=@nifty.ne.jp header.a=rsa-sha256 header.s=default-1th84yt82rvi header.b=TOgTmTQK DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 81DB34BA2E2C Received: from HP-Z230 by mta-snd-e07.mail.nifty.com with ESMTP id <20260824080309399.VTVR.17441.HP-Z230@nifty.com>; Mon, 24 Aug 2026 17:03:09 +0900 From: Takashi Yano <takashi.yano@nifty.ne.jp> To: newlib@sourceware.org Cc: Takashi Yano <takashi.yano@nifty.ne.jp>, Tony Cook <tony@develop-help.com> Subject: [PATCH] newlib: getlocalename_l: Avoid strcpy onto const area on "C" locale Date: Mon, 24 Aug 2026 17:02:28 +0900 Message-ID: <20260824080300.805-1-takashi.yano@nifty.ne.jp> X-Mailer: git-send-email 2.51.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.ne.jp; s=default-1th84yt82rvi; t=1787558589; bh=S0S6HJjvWRiiJmsYKZQZ1OUQ8wekQnTHB2AqBfO9ghg=; h=From:To:Cc:Subject:Date; b=TOgTmTQK8SGSv7FENt5u3xN1gEaJ0/9RvFQHI4h6O+63zNod2BsxBn1uF+FOjnZhkq9d5Qe/ HrDkbk5cXFKPDMbw0+NHPBMkdbJ10p43AxLy6Imt2noUvMOVR0AogaRpkrTdNuQ3ON1xDF0QU2 DmPskS/y1VEtlqQxb472eLPIanxnmS6QabZiGRevUIwRlvn1GOupeXSGf9jKk1fquoy7LWYlOM FPTEUmyDuQbRyIRv4RNX9b5p7dqzbeCt3raDbEhOUOpLsvYKl4OZX5Yz9Dykrdzz+mJhrs6Zck NvUOQ3KFjHKu9+uZ1KyFmhBzeuRllo5MoJwUSvl1yXNeUwBA== X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Newlib mailing list <newlib.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/newlib>, <mailto:newlib-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/newlib/> List-Post: <mailto:newlib@sourceware.org> List-Help: <mailto:newlib-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/newlib>, <mailto:newlib-request@sourceware.org?subject=subscribe> Errors-To: newlib-bounces~patchwork=sourceware.org@sourceware.org |
| Series |
newlib: getlocalename_l: Avoid strcpy onto const area on "C" locale
|
|
Commit Message
Takashi Yano
Aug. 24, 2026, 8:02 a.m. UTC
With the commit a0fe984953dd ("getlocalename_l: allow LC_ALL category"),
the code attempts to copy locale string to `locobj->locale_string`,
in __currentlocale() in _getlocalename_l_r(). However, if `locobj` is
the "C" locale, it points to the const area. This results in a crash.
This patch simply returns "C" when the `locobj` represents the C
locale, instead of cunstructing LC_ALL string from `categories[]`
because all the `categories[]` are always "C" for the C locale.
Fixes: a0fe984953dd ("getlocalename_l: allow LC_ALL category")
Addresses: https://cygwin.com/pipermail/cygwin/2026-August/259965.html
Reported-by: Tony Cook <tony@develop-help.com>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
---
newlib/libc/locale/getlocalename_l.c | 2 ++
1 file changed, 2 insertions(+)
Comments
Patch applied. Thanks. -- Jeff J. On Mon, Aug 24, 2026 at 4:03 AM Takashi Yano <takashi.yano@nifty.ne.jp> wrote: > With the commit a0fe984953dd ("getlocalename_l: allow LC_ALL category"), > the code attempts to copy locale string to `locobj->locale_string`, > in __currentlocale() in _getlocalename_l_r(). However, if `locobj` is > the "C" locale, it points to the const area. This results in a crash. > > This patch simply returns "C" when the `locobj` represents the C > locale, instead of cunstructing LC_ALL string from `categories[]` > because all the `categories[]` are always "C" for the C locale. > > Fixes: a0fe984953dd ("getlocalename_l: allow LC_ALL category") > Addresses: https://cygwin.com/pipermail/cygwin/2026-August/259965.html > Reported-by: Tony Cook <tony@develop-help.com> > Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp> > --- > newlib/libc/locale/getlocalename_l.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/newlib/libc/locale/getlocalename_l.c > b/newlib/libc/locale/getlocalename_l.c > index 1f18f828a..7ad4331b4 100644 > --- a/newlib/libc/locale/getlocalename_l.c > +++ b/newlib/libc/locale/getlocalename_l.c > @@ -63,6 +63,8 @@ _getlocalename_l_r (struct _reent *ptr, int category, > struct __locale_t *locobj) > if (locobj == LC_GLOBAL_LOCALE) > return __currentlocale (__get_global_locale (), > _REENT_GETLOCALENAME_L_BUF (ptr)); > + else if (locobj == __get_C_locale ()) > + return "C"; > return __currentlocale (locobj, locobj->locale_string); > } > if (locobj == LC_GLOBAL_LOCALE) > -- > 2.51.0 > >
diff --git a/newlib/libc/locale/getlocalename_l.c b/newlib/libc/locale/getlocalename_l.c index 1f18f828a..7ad4331b4 100644 --- a/newlib/libc/locale/getlocalename_l.c +++ b/newlib/libc/locale/getlocalename_l.c @@ -63,6 +63,8 @@ _getlocalename_l_r (struct _reent *ptr, int category, struct __locale_t *locobj) if (locobj == LC_GLOBAL_LOCALE) return __currentlocale (__get_global_locale (), _REENT_GETLOCALENAME_L_BUF (ptr)); + else if (locobj == __get_C_locale ()) + return "C"; return __currentlocale (locobj, locobj->locale_string); } if (locobj == LC_GLOBAL_LOCALE)