From nobody Mon Jun 26 16:30:39 2023 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4QqYHP1QB9z4kZh1; Mon, 26 Jun 2023 16:30:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QqYHN1dJbz46Bp; Mon, 26 Jun 2023 16:30:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687797040; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=gXg8FxS8XjnEGBnkp6xIj48wjlqxqCpxyfIEHNtBdqM=; b=Q70Xf9IaLK5Qk8e0N44EWa8ioMqbT4ZvfHHfyucbULRcFaZWaqFPcLjlEJx3gmay/qygGv c502VfQA/g0wMyP/VvZookpfrgyTRI0myjI6pAQMblH5SP8oSyYErsgQNpkmgcIE64AP25 RBtvsdR6IJhSscy2Hr4kOUCT/9FXWA81ErIX2tNZJUYGnnHZZYzeihgtvXgM5dOJlr30E8 EGtSnd2glfbtT+zaUAEag1dmttE0lJlPaG19+ehUWQLucbjKUuiexPChzOEgUFVRVaqL69 We6bFI9q1ZFA9gxiV1Vu4vOMkyhSNvsRhEAcKG7YWgyMxTIj+fJ/3s805Gafrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687797040; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=gXg8FxS8XjnEGBnkp6xIj48wjlqxqCpxyfIEHNtBdqM=; b=fn3arE8vXqI5AbznXqqCL0aQLPkm5d4AacqV9pVGItG+1r4DRIMEuiUEPl/m2BoeS4IWZW tqDGMVmGF9N3Tl2bxT1VuZX8WUHwyZ78TZLX1wvUEKVDczp/meiv7AkHODljZhKYoifhKO uj/rjXX4QfXJ2Ebb3y4kDOn6Dfku7aI4TESomKKtyTqMA4F4k7RJDFU96o/NJQ98f5XxtJ Pdkn8+ZXKqCfL/SNwt+UJkGbqeWoWP9RPdmWZZRlCbXvSmW9fqmEFs0ghjMMjYxtVaEUKY 4keXsod/UjBVcYTUkpcFsDZRThi3kB6dNzMYH46sn8xVsBx2LeLf+QI0mp62bQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1687797040; a=rsa-sha256; cv=none; b=jAovL9T0uMHaitv7i/5qGLRNzI7Qm7o5Phu8qUywKAfZfgQ3JEeacNwHYXiGQ+Qgst+7d1 jzyR+QPJ+LNv+VUleLHC/dD7ZLwn2r2oEhOmGNaZk802OyTNccJz7SeDqGHkbPbC0llvBd s98ZEoVR5duvaJ+du2HPYs0sh1nRTpQoslJ8f8y5gKjyKst81fHAtiy04A0jybMy25N6Zm O4eRvMppq/kO3HhmYhMoisoexfmf17+8XCOPdTNZEkaKH2scjnM9IKYGVS+4n//+9KiycO GTRiJS9njcggw9gyD/+FQ8koCR154uSfpVz4ZL7T8isyDsB84leGsLdj6/Ef/Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4QqYHN0Q0DzHRH; Mon, 26 Jun 2023 16:30:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 35QGUdXV025492; Mon, 26 Jun 2023 16:30:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 35QGUdRk025491; Mon, 26 Jun 2023 16:30:39 GMT (envelope-from git) Date: Mon, 26 Jun 2023 16:30:39 GMT Message-Id: <202306261630.35QGUdRk025491@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 6403f0ac1281 - stable/13 - seq: fix potential NULL ptr reference List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 6403f0ac1281a9f95f387c98ef17f88f59714e56 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=6403f0ac1281a9f95f387c98ef17f88f59714e56 commit 6403f0ac1281a9f95f387c98ef17f88f59714e56 Author: Mariusz Zaborski AuthorDate: 2022-09-30 17:36:04 +0000 Commit: Ed Maste CommitDate: 2023-06-26 16:30:31 +0000 seq: fix potential NULL ptr reference asprintf(3) allocates memory, and there isn't any guarantee of success. MFC after: 2 weeks Obtained from: OpenBSD (cherry picked from commit 94c4f663bab58ec07584786dd76866011d5b2506) --- usr.bin/seq/seq.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/usr.bin/seq/seq.c b/usr.bin/seq/seq.c index 7559dbd9ce20..47ba0b7ce3af 100644 --- a/usr.bin/seq/seq.c +++ b/usr.bin/seq/seq.c @@ -199,8 +199,12 @@ main(int argc, char *argv[]) * loop held true due to a rounding error and we still need to print * 'last'. */ - asprintf(&cur_print, fmt, cur); - asprintf(&last_print, fmt, last); + if (asprintf(&cur_print, fmt, cur) < 0) { + err(1, "asprintf"); + } + if (asprintf(&last_print, fmt, last) < 0) { + err(1, "asprintf"); + } if (strcmp(cur_print, last_print) == 0 && cur != last_shown_value) { fputs(last_print, stdout); fputs(sep, stdout);