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 50a53384 for ; Wed, 29 Jan 2020 11:34:34 +0000 (UTC) Received: (qmail 11377 invoked by uid 550); 29 Jan 2020 11:34:33 -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 4045 invoked from network); 29 Jan 2020 11:21:00 -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=w8jRVh+X4d6xhmv/QsL6 jV4/iuI=; b=BB3CLb4V9fDekcG7G+r9CXku3dnNq3ZE9wnfxAeLJA9Z2+bpXVt/ 0eYkCyRiTQWRuZe/F9UQL6T7wxXMSgb0NQ/DUVeCXkHiK3dFeiCEjdl7XLPnv9fG bX7lDvpYWtAgcxQN/qlHJHWWeTCsq+PDiGYUFXN/IYU31ZhSDSmvg1o= 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=pMi0h6zqUW+nYWNLYstdIOBWVqUUfwGdBYg6obq8s bQf3HXfw86qHjDSkF1LFGc2ry1FSx1FwI/q0TRM9Z9V62WMPNrIU/vZw1HuqZN4/ Ael3C4VCEl1SvenoeuQCko/URmU3OGoswmleMPne1IustJsnAClDx1Imk4uSo1xi Nc= From: =?UTF-8?q?S=C3=B6ren=20Tempel?= To: musl@lists.openwall.com Date: Wed, 29 Jan 2020 12:20:07 +0100 Message-Id: <20200129112007.17575-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 v2] 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..fd7832e4 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; + if (!buf) buf = usridbuf; snprintf(buf, L_cuserid, "%s", pw.pw_name); return buf; }