From unknown Thu Aug 14 22:23:16 2025 X-Loop: help-debbugs@gnu.org Subject: bug#65617: coreutils 9.4: seg.fault in readutmp with systemd Resent-From: Thorsten Kukuk Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Wed, 30 Aug 2023 11:22:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 65617 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: 65617@debbugs.gnu.org X-Debbugs-Original-To: bug-coreutils@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.169339449018200 (code B ref -1); Wed, 30 Aug 2023 11:22:01 +0000 Received: (at submit) by debbugs.gnu.org; 30 Aug 2023 11:21:30 +0000 Received: from localhost ([127.0.0.1]:52245 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbJGM-0004jU-96 for submit@debbugs.gnu.org; Wed, 30 Aug 2023 07:21:30 -0400 Received: from lists.gnu.org ([2001:470:142::17]:52214) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbJGH-0004jD-3s for submit@debbugs.gnu.org; Wed, 30 Aug 2023 07:21:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbJG4-0003iJ-4m for bug-coreutils@gnu.org; Wed, 30 Aug 2023 07:21:12 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbJG2-0006FP-2N for bug-coreutils@gnu.org; Wed, 30 Aug 2023 07:21:11 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 1005821846 for ; Wed, 30 Aug 2023 11:21:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1693394467; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=uqTVRiz8LhPucMMiufkP50f0LXqso73nw0GeuXr8EaA=; b=DrJWcQx26c2bUUGpYz5CLLncTwjXNgF9p6rs7RkDNP5v+VoEtjlkWvrp2L0YsJpUjdTMcl 5bxh4wvNxJMDFbbna4CRcus7nhZVX8oTs/Qf/Vlz6qv3YTNF5KEoWDhqhzv/gKBP4u/fWq Uhq2rhvPKJyaxsvytSK7W60OyNyYxsY= Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 0B1112C142 for ; Wed, 30 Aug 2023 11:21:07 +0000 (UTC) Received: by wotan.suse.de (Postfix, from userid 358) id 0239169BC; Wed, 30 Aug 2023 11:21:07 +0000 (UTC) Date: Wed, 30 Aug 2023 11:21:06 +0000 From: Thorsten Kukuk Message-ID: <20230830112106.GA28997@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.10.1 (2018-07-13) Received-SPF: pass client-ip=195.135.220.28; envelope-from=kukuk@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.2 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: coreutils 9.4 with the --enable-systemd option seg.faults in lib/readutmp.c, line 801: for (session_ptr = sessions; *session_ptr != NULL; session_ptr++) If there is no session, "sessions" is NULL and "*session_ptr" will dereference a NULL pointer. Affected are who, pinky and uptime. Content analysis details: (1.2 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.2 (/) coreutils 9.4 with the --enable-systemd option seg.faults in lib/readutmp.c, line 801: for (session_ptr = sessions; *session_ptr != NULL; session_ptr++) If there is no session, "sessions" is NULL and "*session_ptr" will dereference a NULL pointer. Affected are who, pinky and uptime. A simple fix: diff --git a/lib/readutmp.c b/lib/readutmp.c index 0173b7e0c1..e99158677c 100644 --- a/lib/readutmp.c +++ b/lib/readutmp.c @@ -795,7 +795,7 @@ read_utmp_from_systemd (idx_t *n_entries, STRUCT_UTMP **utmp_buf, int options) { char **sessions; int num_sessions = sd_get_sessions (&sessions); - if (num_sessions >= 0) + if (num_sessions > 0) { char **session_ptr; for (session_ptr = sessions; *session_ptr != NULL; session_ptr++) -- Thorsten Kukuk, Distinguished Engineer, Senior Architect, Future Technologies SUSE Software Solutions Germany GmbH, Frankenstraße 146, 90461 Nuernberg, Germany Managing Director: Ivo Totev, Andrew McDonald, Werner Knoblich (HRB 36809, AG Nürnberg) From unknown Thu Aug 14 22:23:16 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Thorsten Kukuk Subject: bug#65617: closed (Re: bug#65617: coreutils 9.4: seg.fault in readutmp with systemd) Message-ID: References: <474722d1-d314-09b1-9302-2c920a8bed12@cs.ucla.edu> <20230830112106.GA28997@suse.com> X-Gnu-PR-Message: they-closed 65617 X-Gnu-PR-Package: coreutils Reply-To: 65617@debbugs.gnu.org Date: Thu, 31 Aug 2023 01:30:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1693445402-16126-1" This is a multi-part message in MIME format... ------------=_1693445402-16126-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #65617: coreutils 9.4: seg.fault in readutmp with systemd which was filed against the coreutils package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 65617@debbugs.gnu.org. --=20 65617: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D65617 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1693445402-16126-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 65617-done) by debbugs.gnu.org; 31 Aug 2023 01:29:30 +0000 Received: from localhost ([127.0.0.1]:54367 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbWV0-0004B9-3u for submit@debbugs.gnu.org; Wed, 30 Aug 2023 21:29:30 -0400 Received: from mail.cs.ucla.edu ([131.179.128.66]:57192) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbWUu-0004Aq-SK for 65617-done@debbugs.gnu.org; Wed, 30 Aug 2023 21:29:28 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.cs.ucla.edu (Postfix) with ESMTP id 096393C011BD5; Wed, 30 Aug 2023 18:29:11 -0700 (PDT) Received: from mail.cs.ucla.edu ([127.0.0.1]) by localhost (mail.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id T5GA6JWiQTXH; Wed, 30 Aug 2023 18:29:10 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by mail.cs.ucla.edu (Postfix) with ESMTP id 5AF233C011BD9; Wed, 30 Aug 2023 18:29:10 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.cs.ucla.edu 5AF233C011BD9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.ucla.edu; s=9D0B346E-2AEB-11ED-9476-E14B719DCE6C; t=1693445350; bh=KNhvX/MRvvHtSop6FTTBjh5/h/cCvIx8kP4L2CMMwU4=; h=Message-ID:Date:MIME-Version:To:From; b=GMYfelwqDfR2y6hQpDHVnC5kNwFjg6Mbj/7Foy0I+li8DEiFFKH5k28qKkG6kmyk5 ntj1Oy+BnjUCi++fRvrU0JAbmnz9iwAaJ+VbdqS9QIvadt5Wo6CVVXX/IljyyYScWr uTrdyovNgLmCnBKBH6D9Qkj2XtGwtq1YLJIJSedG/vmI77hWrdbPFPu/sC27OnJ339 Yd7+BEZETRe9UIBvK3eWpuzXPkRuTHgCxI/vRhZOCIOs4Ai/YVgKdCoQLcfRzi9D9k ivoyJePQtmgYuSeSuEc+5vB+rUF245aWccu8Ki/Xw/i0zhriUEnru15yE6Asv8KElr t9o9+CUai9P4w== X-Virus-Scanned: amavisd-new at mail.cs.ucla.edu Received: from mail.cs.ucla.edu ([127.0.0.1]) by localhost (mail.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id alEGWcQ6TBnd; Wed, 30 Aug 2023 18:29:10 -0700 (PDT) Received: from [192.168.1.9] (cpe-172-91-119-151.socal.res.rr.com [172.91.119.151]) by mail.cs.ucla.edu (Postfix) with ESMTPSA id 28AB73C011BD5; Wed, 30 Aug 2023 18:29:10 -0700 (PDT) Content-Type: multipart/mixed; boundary="------------R91fq8atdQCwn2mCIR072xpq" Message-ID: <474722d1-d314-09b1-9302-2c920a8bed12@cs.ucla.edu> Date: Wed, 30 Aug 2023 18:29:09 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: bug#65617: coreutils 9.4: seg.fault in readutmp with systemd Content-Language: en-US To: Thorsten Kukuk References: <20230830112106.GA28997@suse.com> From: Paul Eggert Organization: UCLA Computer Science Department In-Reply-To: <20230830112106.GA28997@suse.com> X-Spam-Score: -1.0 (-) X-Debbugs-Envelope-To: 65617-done Cc: 65617-done@debbugs.gnu.org, Gnulib bugs X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.0 (--) This is a multi-part message in MIME format. --------------R91fq8atdQCwn2mCIR072xpq Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Thanks for reporting that. I installed the attached patch into Gnulib and this should appear in the next coreutils release. --------------R91fq8atdQCwn2mCIR072xpq Content-Type: text/x-patch; charset=UTF-8; name="0001-readutmp-fix-core-dump-if-enable-systemd.patch" Content-Disposition: attachment; filename="0001-readutmp-fix-core-dump-if-enable-systemd.patch" Content-Transfer-Encoding: base64 RnJvbSAxZTZhMjZmOTMxMmJiNDdlMDcwZjk0YjE3YjE0ZGMxYTZmZmJiNzRmIE1vbiBTZXAg MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBQYXVsIEVnZ2VydCA8ZWdnZXJ0QGNzLnVjbGEuZWR1 PgpEYXRlOiBXZWQsIDMwIEF1ZyAyMDIzIDE4OjI2OjUyIC0wNzAwClN1YmplY3Q6IFtQQVRD SF0gcmVhZHV0bXA6IGZpeCBjb3JlIGR1bXAgaWYgLS1lbmFibGUtc3lzdGVtZApNSU1FLVZl cnNpb246IDEuMApDb250ZW50LVR5cGU6IHRleHQvcGxhaW47IGNoYXJzZXQ9VVRGLTgKQ29u dGVudC1UcmFuc2Zlci1FbmNvZGluZzogOGJpdAoKUHJvYmxlbSByZXBvcnRlZCBieSBUaG9y c3RlbiBLdWt1ayA8aHR0cHM6Ly9idWdzLmdudS5vcmcvNjU2MTc+LgoqIGxpYi9yZWFkdXRt cC5jIChyZWFkX3V0bXBfZnJvbV9zeXN0ZW1kKToKRG9u4oCZdCBhc3N1bWUgc2Vzc2lvbl9w dHIgIT0gTlVMTCBpZiBudW1fc2Vzc2lvbnMgPT0gMC4KSW4gcHJhY3RpY2UgaXQgY2FuIGJl IG51bGwsIGFuZCB0aGUgbWFuIHBhZ2UgT0tzIHRoaXMgYmVoYXZpb3IuCi0tLQogQ2hhbmdl TG9nICAgICAgfCA4ICsrKysrKysrCiBsaWIvcmVhZHV0bXAuYyB8IDIgKy0KIDIgZmlsZXMg Y2hhbmdlZCwgOSBpbnNlcnRpb25zKCspLCAxIGRlbGV0aW9uKC0pCgpkaWZmIC0tZ2l0IGEv Q2hhbmdlTG9nIGIvQ2hhbmdlTG9nCmluZGV4IGQ0YjIyODczMDcuLjljOWM4OTYzOGMgMTAw NjQ0Ci0tLSBhL0NoYW5nZUxvZworKysgYi9DaGFuZ2VMb2cKQEAgLTEsMyArMSwxMSBAQAor MjAyMy0wOC0zMCAgUGF1bCBFZ2dlcnQgIDxlZ2dlcnRAY3MudWNsYS5lZHU+CisKKwlyZWFk dXRtcDogZml4IGNvcmUgZHVtcCBpZiAtLWVuYWJsZS1zeXN0ZW1kCisJUHJvYmxlbSByZXBv cnRlZCBieSBUaG9yc3RlbiBLdWt1ayA8aHR0cHM6Ly9idWdzLmdudS5vcmcvNjU2MTc+Lgor CSogbGliL3JlYWR1dG1wLmMgKHJlYWRfdXRtcF9mcm9tX3N5c3RlbWQpOgorCURvbuKAmXQg YXNzdW1lIHNlc3Npb25fcHRyICE9IE5VTEwgaWYgbnVtX3Nlc3Npb25zID09IDAuCisJSW4g cHJhY3RpY2UgaXQgY2FuIGJlIG51bGwsIGFuZCB0aGUgbWFuIHBhZ2UgT0tzIHRoaXMgYmVo YXZpb3IuCisKIDIwMjMtMDgtMzAgIEJydW5vIEhhaWJsZSAgPGJydW5vQGNsaXNwLm9yZz4K IAogCWRvYzogTWVudGlvbiB0aGUgbW9kdWxlICd3Y2hhci1zaW5nbGUnLgpkaWZmIC0tZ2l0 IGEvbGliL3JlYWR1dG1wLmMgYi9saWIvcmVhZHV0bXAuYwppbmRleCAwMTczYjdlMGMxLi5l OTkxNTg2NzdjIDEwMDY0NAotLS0gYS9saWIvcmVhZHV0bXAuYworKysgYi9saWIvcmVhZHV0 bXAuYwpAQCAtNzk1LDcgKzc5NSw3IEBAIHJlYWRfdXRtcF9mcm9tX3N5c3RlbWQgKGlkeF90 ICpuX2VudHJpZXMsIFNUUlVDVF9VVE1QICoqdXRtcF9idWYsIGludCBvcHRpb25zKQogICAg IHsKICAgICAgIGNoYXIgKipzZXNzaW9uczsKICAgICAgIGludCBudW1fc2Vzc2lvbnMgPSBz ZF9nZXRfc2Vzc2lvbnMgKCZzZXNzaW9ucyk7Ci0gICAgICBpZiAobnVtX3Nlc3Npb25zID49 IDApCisgICAgICBpZiAobnVtX3Nlc3Npb25zID4gMCkKICAgICAgICAgewogICAgICAgICAg IGNoYXIgKipzZXNzaW9uX3B0cjsKICAgICAgICAgICBmb3IgKHNlc3Npb25fcHRyID0gc2Vz c2lvbnM7ICpzZXNzaW9uX3B0ciAhPSBOVUxMOyBzZXNzaW9uX3B0cisrKQotLSAKMi4zOS4y Cgo= --------------R91fq8atdQCwn2mCIR072xpq-- ------------=_1693445402-16126-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 30 Aug 2023 11:21:30 +0000 Received: from localhost ([127.0.0.1]:52245 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbJGM-0004jU-96 for submit@debbugs.gnu.org; Wed, 30 Aug 2023 07:21:30 -0400 Received: from lists.gnu.org ([2001:470:142::17]:52214) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbJGH-0004jD-3s for submit@debbugs.gnu.org; Wed, 30 Aug 2023 07:21:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbJG4-0003iJ-4m for bug-coreutils@gnu.org; Wed, 30 Aug 2023 07:21:12 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbJG2-0006FP-2N for bug-coreutils@gnu.org; Wed, 30 Aug 2023 07:21:11 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 1005821846 for ; Wed, 30 Aug 2023 11:21:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1693394467; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=uqTVRiz8LhPucMMiufkP50f0LXqso73nw0GeuXr8EaA=; b=DrJWcQx26c2bUUGpYz5CLLncTwjXNgF9p6rs7RkDNP5v+VoEtjlkWvrp2L0YsJpUjdTMcl 5bxh4wvNxJMDFbbna4CRcus7nhZVX8oTs/Qf/Vlz6qv3YTNF5KEoWDhqhzv/gKBP4u/fWq Uhq2rhvPKJyaxsvytSK7W60OyNyYxsY= Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 0B1112C142 for ; Wed, 30 Aug 2023 11:21:07 +0000 (UTC) Received: by wotan.suse.de (Postfix, from userid 358) id 0239169BC; Wed, 30 Aug 2023 11:21:07 +0000 (UTC) Date: Wed, 30 Aug 2023 11:21:06 +0000 From: Thorsten Kukuk To: bug-coreutils@gnu.org Subject: coreutils 9.4: seg.fault in readutmp with systemd Message-ID: <20230830112106.GA28997@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.10.1 (2018-07-13) Received-SPF: pass client-ip=195.135.220.28; envelope-from=kukuk@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.2 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: coreutils 9.4 with the --enable-systemd option seg.faults in lib/readutmp.c, line 801: for (session_ptr = sessions; *session_ptr != NULL; session_ptr++) If there is no session, "sessions" is NULL and "*session_ptr" will dereference a NULL pointer. Affected are who, pinky and uptime. Content analysis details: (1.2 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.2 (/) coreutils 9.4 with the --enable-systemd option seg.faults in lib/readutmp.c, line 801: for (session_ptr = sessions; *session_ptr != NULL; session_ptr++) If there is no session, "sessions" is NULL and "*session_ptr" will dereference a NULL pointer. Affected are who, pinky and uptime. A simple fix: diff --git a/lib/readutmp.c b/lib/readutmp.c index 0173b7e0c1..e99158677c 100644 --- a/lib/readutmp.c +++ b/lib/readutmp.c @@ -795,7 +795,7 @@ read_utmp_from_systemd (idx_t *n_entries, STRUCT_UTMP **utmp_buf, int options) { char **sessions; int num_sessions = sd_get_sessions (&sessions); - if (num_sessions >= 0) + if (num_sessions > 0) { char **session_ptr; for (session_ptr = sessions; *session_ptr != NULL; session_ptr++) -- Thorsten Kukuk, Distinguished Engineer, Senior Architect, Future Technologies SUSE Software Solutions Germany GmbH, Frankenstraße 146, 90461 Nuernberg, Germany Managing Director: Ivo Totev, Andrew McDonald, Werner Knoblich (HRB 36809, AG Nürnberg) ------------=_1693445402-16126-1-- From unknown Thu Aug 14 22:23:16 2025 X-Loop: help-debbugs@gnu.org Subject: bug#65617: coreutils 9.4: seg.fault in readutmp with systemd Resent-From: Bruno Haible Original-Sender: "Debbugs-submit" Resent-CC: bug-coreutils@gnu.org Resent-Date: Thu, 31 Aug 2023 09:38:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65617 X-GNU-PR-Package: coreutils X-GNU-PR-Keywords: To: bug-gnulib@gnu.org, 65617-done@debbugs.gnu.org Cc: Thorsten Kukuk , Paul Eggert Received: via spool by 65617-done@debbugs.gnu.org id=D65617.169347465111096 (code D ref 65617); Thu, 31 Aug 2023 09:38:01 +0000 Received: (at 65617-done) by debbugs.gnu.org; 31 Aug 2023 09:37:31 +0000 Received: from localhost ([127.0.0.1]:54865 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbe7H-0002st-Hq for submit@debbugs.gnu.org; Thu, 31 Aug 2023 05:37:31 -0400 Received: from mo4-p01-ob.smtp.rzone.de ([85.215.255.50]:41643) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qbe7C-0002sg-Eq for 65617-done@debbugs.gnu.org; Thu, 31 Aug 2023 05:37:30 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1693474625; cv=none; d=strato.com; s=strato-dkim-0002; b=kBLRdj1UeDRR6UCJPuh5qBdPst9PwNTwzxDhP41GsGo51sq4mr7iMCc6N4AQYkLfrd oncsdt29zcSKW4rlzXYanNn8Uz1sgmBHs6wMGl9mErslAyKgld7HZWM71ZPX1bpOEbMU lGlhmsfszfEftA3xtRbS53xxw3c3h1WD4t4u85zkWQNLG7wjkfk1QS6UqnQ7RioEPUky yG4tawzkAAOoMWQVDTPHZahgrOMGuCEf3MzK5NfTmPZaJ/UQwxKJkYqT30LMUxRp9oRT rUMF9V6BE/pffH8QJsCfmPEo98dZZZYVdLZkj4EdgymGldGbipe8m9pESqnsMcWDqcQ5 5rPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1693474625; s=strato-dkim-0002; d=strato.com; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=4W1hxB64eIIz6RVs05OWlEAxWzsFlYdXOgS4y/SwJdg=; b=qn30PwnzJGkOylQlS7FxsuMw+atnE97YQrCknSbx1JipgdkMq1vq33X9xFt73CxRG1 IK+PVadoeCxDy5rcYtprS8sVD+5dOdsvGtJxqoOQpLUisfIjqoBHhZsZsv77NbGvqaTf Lq18T26duXhX8Xj148vI3JkrdflOWWk0YNU7eSBnpW3LXEA2JXeNm4tzpedUwtM7n2Qw mrxWuYvw5NpnYfjAKbByoc5MSFnPNCRmPBaqdsytZktpxJRWplmPHVLtH/7ANg6pMwz7 XTvIsP6le4SlrUV0qbl+/Ckx4OJLm+QQFJH+xU3jfvoi1GMRSXnNpnbq1ko+Y1pOmEqc SPPQ== ARC-Authentication-Results: i=1; strato.com; arc=none; dkim=none X-RZG-CLASS-ID: mo01 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1693474625; s=strato-dkim-0002; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=4W1hxB64eIIz6RVs05OWlEAxWzsFlYdXOgS4y/SwJdg=; b=bbLJBSCbvwWtyzE78Mn0CcGhoe3fnus2waT/C3pCovdQ3bvP3+4Li4Vl44Hz6K8SBD +kenvtDN96s9gx2hSpWgTWg7V+XVHL71h4+wTAryNYsm+TDpdiI02u2wq/+o6m/Mty4S V8oZ2IuoTteQIH37CbHuC1uiFNNKjUtIthUQRHAFsgvzuEG4nFHpmQ4FDNAQiPDEpnYD VhgcVa5HiopW/eUDHWEIwcGiJG8xn1o0MtvSXQ2pvOcVQ0HWCIhogIpKa4IcgKHaRPui USUY/QcKU7pm9xEmoODzATaNY/sFaUtuCiO2mCKwu+uHqS49zyozorqz2v5MYO0PNHrI pIbQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; t=1693474625; s=strato-dkim-0003; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Cc:Date: From:Subject:Sender; bh=4W1hxB64eIIz6RVs05OWlEAxWzsFlYdXOgS4y/SwJdg=; b=U+3AucVAYtwmYLL7mkMvDCLbHqZx4xOQ5gw3wk7IAbWORzZtizv2RNc2m8bhiq3I9P laJQNNxPpad2DWDaIdBg== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH0WWb0LN8XZoH94zq68+3cfpPE2PRSElrKzrvxtB+8jmt43OVJCw==" Received: from nimes.localnet by smtp.strato.de (RZmta 49.8.2 AUTH) with ESMTPSA id z9213ez7V9b56mY (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Thu, 31 Aug 2023 11:37:05 +0200 (CEST) From: Bruno Haible Date: Thu, 31 Aug 2023 11:37:05 +0200 Message-ID: <2519178.4XsnlVU6TS@nimes> In-Reply-To: <474722d1-d314-09b1-9302-2c920a8bed12@cs.ucla.edu> References: <20230830112106.GA28997@suse.com> <474722d1-d314-09b1-9302-2c920a8bed12@cs.ucla.edu> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Paul Eggert wrote: > I installed the attached patch into Gnulib > and this should appear in the next coreutils release. Unfortunately, this patch introduces a memory leak: If num_sessions == 0 and sessions != NULL (which can happen, according to the man page), we need to call free (sessions). This patch fixes it. 2023-08-31 Bruno Haible readutmp: Fix memory leak introduced by last commit. * lib/readutmp.c (read_utmp_from_systemd): If num_sessions == 0 and sessions != NULL, do call free (sessions). diff --git a/lib/readutmp.c b/lib/readutmp.c index e99158677c..ec09feb59b 100644 --- a/lib/readutmp.c +++ b/lib/readutmp.c @@ -795,7 +795,7 @@ read_utmp_from_systemd (idx_t *n_entries, STRUCT_UTMP **utmp_buf, int options) { char **sessions; int num_sessions = sd_get_sessions (&sessions); - if (num_sessions > 0) + if (num_sessions >= 0 && sessions != NULL) { char **session_ptr; for (session_ptr = sessions; *session_ptr != NULL; session_ptr++)