From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.2 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by inbox.vuxu.org (OpenSMTPD) with SMTP id e150f52a for ; Tue, 28 Jan 2020 20:01:54 +0000 (UTC) Received: (qmail 9415 invoked by uid 550); 28 Jan 2020 20:01:53 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 5591 invoked from network); 28 Jan 2020 19:41:13 -0000 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=soeren-tempel.net; h=from :to:subject:date:message-id:mime-version :content-transfer-encoding; s=opensmtpd; bh=KOBGrHEZZTFf1NsO95T5 PlzsSlw=; b=IJkwxCyUM3bfqwGN6lqsTOJ+ojn1eOiTp/I+jEQPX9GdZ0h2VUyD PgDG6vDkzOriiw4Yxtxzro6lpJW39KoQSZc50qWtdO0PjflDmgexSpmw6299uelM NSEwt2jeCwH/vVMqRniuUDFQkycdi+g/y74oNSWVxk9vUiQ5uBeWrn0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=soeren-tempel.net; h=from:to :subject:date:message-id:mime-version:content-transfer-encoding; q=dns; s=opensmtpd; b=nfLjzteqKpkzy/1Pyx1cq96aKBjJAwXUySsAUoyTf 9wNP+9+Zc4Zk54QLmJPvfiK7IUz2twRMZXLyNQEdftAFqHVkxQR5whCorlzAgklg mMN5B0PH4vAG9e6nGdYyCYlWQfprNOcVuP2eG4EDTbdQBlESgbNqthljHfVrLww9 HA= From: =?UTF-8?q?S=C3=B6ren=20Tempel?= To: musl@lists.openwall.com Date: Tue, 28 Jan 2020 20:40:32 +0100 Message-Id: <20200128194032.4370-1-soeren+git@soeren-tempel.net> X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [musl] [PATCH] cuserid: support invocation with a NULL pointer argument I did not manage to find a copy of IEEE 1003.1-1988 (the last POSIX version where cuserid was last standardized) the Single UNIX specification version 2 does state the following though [1]: If s is a null pointer, this representation is generated in an area that may be static (and thus overwritten by subsequent calls to cuserid()), the address of which is returned. Even though this a legacy function it would therefore be nice for musl to support usage with a NULL pointer. I ran into this on Alpine Linux when using cdparanoia [2] which uses cuserid like this and therefore caused a crash on my system. [1]: https://pubs.opengroup.org/onlinepubs/7908799/xsh/cuserid.html [2]: https://xiph.org/paranoia/index.html --- src/legacy/cuserid.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/legacy/cuserid.c b/src/legacy/cuserid.c index 4e78798d..19206ba4 100644 --- a/src/legacy/cuserid.c +++ b/src/legacy/cuserid.c @@ -5,10 +5,12 @@ char *cuserid(char *buf) { + static char *usridbuf[L_cuserid]; struct passwd pw, *ppw; long pwb[256]; if (getpwuid_r(geteuid(), &pw, (void *)pwb, sizeof pwb, &ppw)) return 0; + buf = (buf) ? buf : usridbuf; snprintf(buf, L_cuserid, "%s", pw.pw_name); return buf; }