delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2025/03/24/12:07:10

DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 52OG79rN2350285
Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com
Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com
DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 52OG79rN2350285
Authentication-Results: delorie.com;
dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=v6iuu3ET
X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D1BFA3858C48
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1742832427;
bh=xYL904BgE6sAGRGU97Zdz99+BfZIoI8Qc8ngWvGJVp0=;
h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post:
List-Help:List-Subscribe:From:Reply-To:From;
b=v6iuu3ETTuSBKYZHuzm4Oatr85ohDNrO12BppTxYJhDGV8OFVeICgUV7I4DmUuloX
P3Nt22uo9hxUab5SZi0CImUsWEJ4ETGcVFTss5d0y/rJhSi+yX0xYTC/3LXYIqd7pP
8FjC72fAjF4ap0XdT+I42YLXNd1eklccA/4ECOGQ=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C5F933858423
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C5F933858423
ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1742821976; cv=pass;
b=jqWOvERjGbPyts53sE9W7dbLOqpGGc2Brcu5JzGU+w6PAh1ovWvj1+cf6KT9i5ohogI8pD7adh4lNH/sHg9hjDVB+eb9OWb2LJxCe9n57QqOimEdEqLk1hWT6xlCMaBFbv+/jk/0fzp86urKJvkb4YXFbj6fMkmbig0ICT/bDDM=
ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key;
t=1742821976; c=relaxed/simple;
bh=Je3hLeE7txyfsTSiSEsBt9U803kzsDzGfxsbiXvA1SY=;
h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID:
MIME-Version;
b=kI2cA4RxwU6ygldUdcX5og9PlRm81jpUwWHZliBuuL8Oo2zTnIa+t1rHtmWhAI4NI4lChgyPjbBwl34dbWMhwfD2zHM6B1/fYnQaZ5PECCCXwtdR4bFoQpXdP/1igck1NoTdR9dgfgtB6S04zVXoa9312UYRm0M3NdPCNoRGcME=
ARC-Authentication-Results: i=2; server2.sourceware.org
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C5F933858423
ARC-Seal: i=1; a=rsa-sha256; t=1742821964; cv=none;
d=strato.com; s=strato-dkim-0002;
b=Z9cOOrQjcOybD3hYOKLH/VqvdeBYuPJUHzmTYCXVyZx2SdteQMXkzAteHJQ3Ew3VTn
/mKy3xLi0QuONfw8IftfPnoFgVeUwiRx6nXPvGWA7GWSoewyquScdA2rrFw8bcKPlMd6
7lKqAsx8Gtb03JtkKWOy2zxGKyPbxrrKkx+RdzEJxRsmS6RVzOiAaNy42NIPL2WCVG7f
SMoeHVCJxJtldfhjqefu10scGSb0c55pJqTUHxwavEcFPWku+qyD9ecbqI1O0Ja/asZ+
3RwVDwO5J1wcyauz4usA7LYx9NIBGUtzZTVw+3uUmC4XCajXZ8KB3z7PPdCMSF+LqQch
5vCA==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1742821964;
s=strato-dkim-0002; d=strato.com;
h=Message-ID:Date:Subject:To:From:Cc:Date:From:Subject:Sender;
bh=meAV9zd+V3fJpvxabFsMSsD87ugMqtzeq4LNHeXlgl8=;
b=e7FjkBafgQ0uP8Q8SrL3kQYKThrIYK/9YF+04TWvTlJxt3qhgwT5KF4Bye/iDfKnE2
5Ne4E9AffeODiSWr39IAq+D4SVTEY1TX52saqNyfiABegQCajoWBNU0XHntQ2LW7//mS
sBUpJezbVZEu9DCZaHq39kvV8uNqX4I4tSYoIySdNk4uXrXbCV9+pPLGcVDYx1rJjtTm
QE4+qQ17ReqTS7sWlOwiinZEHFOHcBVl+mvlDluAXInh1ThYYgN72+Zi+760oHL59rVO
NZrD1tA0fvsXHJBFbOtvyQLiMdWCn3NSAdNKd7It4insqjCESsMDJNrgOhD5OC6m1N+V
4WbA==
ARC-Authentication-Results: i=1; strato.com;
arc=none;
dkim=none
X-RZG-CLASS-ID: mo00
X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlLnY4jECd2hdUURIbZgL8PX2QiTuZ3cdB8X/nqmqaQGBSjfO4YvGI1HAKGtVlp8lF"
To: cygwin AT cygwin DOT com
Subject: two bugs in getlocalename_l
Date: Mon, 24 Mar 2025 14:12:43 +0100
Message-ID: <4134860.iTQEcLzFEP@nimes>
Organization: GNU
MIME-Version: 1.0
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.30
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Bruno Haible via Cygwin <cygwin AT cygwin DOT com>
Reply-To: Bruno Haible <bruno AT clisp DOT org>
Sender: "Cygwin" <cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com>

Hi,

It's good to see the addition of getlocalename_l from POSIX [1] in Cygwin 3.6.0.

[1] https://pubs.opengroup.org/onlinepubs/9799919799/functions/getlocalename_l.html

However, there are two bugs:


1) If the second argument is LC_GLOBAL_LOCALE, the return value is garbage.

How to reproduce:
========================== foo.c ============================
#include <locale.h>
#include <stdio.h>

int main ()
{
  const char *ret = getlocalename_l (LC_COLLATE, LC_GLOBAL_LOCALE);
  printf ("ret as a pointer = %p\n", ret);
  printf ("ret as a string = %s\n", ret);
  return 2;
}
===============================================================
$ x86_64-pc-cygwin-gcc -Wall -ggdb foo.c
$ ./a
ret as a pointer = 0x1f
$ echo $?
0

Bug 1: The return value is 0x1f, which is not a valid string.
Bug 2: The second printf, instead of crashing, terminates the
       program with exit code 0 (faking successful execution!).


2) If the first value is LC_ALL, the return value is NULL.
This can be seen from cygwin/newlib/libc/locale/getlocalename_l.c.

But POSIX [1] specific a valid return value in this case.

The comments in that source file are also wrong:

  - "If
     the value is LC_ALL or is not a supported locale category value (see
     <<setlocale>>), <<getlocalename_l>> shall fail."
    No, that's now how it is specified.
    <https://www.austingroupbugs.net/view.php?id=1220> specified it this
    way, but <https://www.austingroupbugs.net/view.php?id=1741> added the
    LC_ALL support.

  - "<<getlocalename_l>> is POSIX-1.2008 since Base Specification Issue 8"
    No, it was introduced in POSIX-1.2024.


Bruno




-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019