From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 1DABB13997D for ; Wed, 13 Nov 2019 12:53:33 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D8885E08F7; Wed, 13 Nov 2019 12:53:31 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id BA0A5E08E0 for ; Wed, 13 Nov 2019 12:53:31 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id B3DA534CD77 for ; Wed, 13 Nov 2019 12:53:30 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id A7563824 for ; Wed, 13 Nov 2019 12:53:27 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1573649540.7ba3ab567aee55dfae0779a3d76c535fea2023d1.grobian@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: / X-VCS-Repository: proj/portage-utils X-VCS-Files: qlop.c X-VCS-Directories: / X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: 7ba3ab567aee55dfae0779a3d76c535fea2023d1 X-VCS-Branch: master Date: Wed, 13 Nov 2019 12:53:27 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 8d42fc44-35bd-4f5b-8554-1ef208141394 X-Archives-Hash: 6f7fb2d9b3e9b898420d0defcb56ea48 commit: 7ba3ab567aee55dfae0779a3d76c535fea2023d1 Author: Fabian Groffen gentoo org> AuthorDate: Wed Nov 13 12:52:20 2019 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Wed Nov 13 12:52:20 2019 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=7ba3ab56 qlop: check return from localtime in fmt_date bogus input can result in NULL, crashing strftime Thanks Agostino Sarubbo Signed-off-by: Fabian Groffen gentoo.org> qlop.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/qlop.c b/qlop.c index 601ad87..95cd64b 100644 --- a/qlop.c +++ b/qlop.c @@ -204,13 +204,14 @@ static char _date_buf[48]; static char *fmt_date(struct qlop_mode *flags, time_t ts, time_t te) { time_t t = flags->do_endtime ? te : ts; + struct tm lt; - if (flags->do_machine) + if (flags->do_machine || localtime_r(&t, <) == NULL) snprintf(_date_buf, sizeof(_date_buf), "%zd", (size_t)t); else strftime(_date_buf, sizeof(_date_buf), - "%Y-%m-%dT%H:%M:%S", localtime(&t)); + "%Y-%m-%dT%H:%M:%S", <); return _date_buf; }