From nobody Mon Apr 17 19:51:13 2023 X-Original-To: dev-commits-src-all@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 4Q0d353DfWz456qP; Mon, 17 Apr 2023 19:51:13 +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 4Q0d352j1Jz4ZWL; Mon, 17 Apr 2023 19:51:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681761073; 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=BNePrzkEbvVqXdpZnekNG/G2yo3EpyjzDbgYKz0UOJA=; b=uuurgSsJMUsAUV3JYcOcWyz5sHjq218U4864p678cEoqFQppXKYmllw7NdemzjqvjjrkDW KZbAV3i9KHlxw3cAuUJ0LLPECWFebFaA4IUO0Y02WkIy63blnGN2KQfH2juMgpS7rc4aYH Qd5AK3Itr3dFi8pGsGRIojxQ80Zh+UWTGvdYhs5y9fSh7h3AKCLrUr/z1kAonWaPOT6SJm GHswYkF46KwxRT9SnCQu5SpwwmPgIR6gNwy9TiTTjcczwDFPX2YoZDq8y0+iEvUem6Lj8i vNKxQtBPdno+JNUbfqIatqsObT6r7Fxuj0fQ+Pp5wIdyzA3y3Ykds4OgIy6cNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681761073; 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=BNePrzkEbvVqXdpZnekNG/G2yo3EpyjzDbgYKz0UOJA=; b=EeHmpQ/srgPQcVR1jEANpEXKu20Xdmf8Zfs2k02YMUs373qYuacIqm1AmrtAG0HvYaU2Ko X7Js89gBu9j+o++2hLPAa6PObdb+ORPdVEwXAxWyXuixv1TJkymCHFnxKuwqTLhLii9i7J rn8ePPJTDThUcCSPeH7guIdXc1QC6iLML8m0wb/FqkhTyT5Cz71/MF32J5btM1bkDrRvMb wXW65BSikBiigZ11AjPHz5AFX74HwrknK9T4kc8wEU9+vvP7oLGN1PKrjXeqtYhNNH6cx4 lxoVrQSWLpR5oQ3mJt/CtTT0MCiIXeM7VI/XuuL//k11yXRjgGSV4RVSmsMPUQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1681761073; a=rsa-sha256; cv=none; b=D1CtFAuUUlRp3jOQf9kUJYNjosRVMI+omu2UsnY/KooxLVoip2l3pHhfqsdiLkcIFPSa03 gVZ47Tqresbfwdt31Z1NLyGGL4c+hoMKi42liyhwiyysaQOApeRffBXRu+7TxvHyxpWLyz qI8TK1wWz8NmrDmY0qc6CUrLT4PLIx+2Z4DjyB2zLXszHSKB1+P3tLSstI8poIbYmsSeK6 SQLyAxau01KZ4/jtLCWjQFrO0pMzDq/Ug3MFVNECNlqmKGfigf8SP7HP5u1JokbCZQENH0 g17CEQBRp/ot1yd9ZXLpj2VKtskWfV02EmMd9o5+Z0qFRG1MmG2DOLxSRoObPQ== 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 4Q0d351klrzjFD; Mon, 17 Apr 2023 19:51:13 +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 33HJpDFb074917; Mon, 17 Apr 2023 19:51:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 33HJpDaO074916; Mon, 17 Apr 2023 19:51:13 GMT (envelope-from git) Date: Mon, 17 Apr 2023 19:51:13 GMT Message-Id: <202304171951.33HJpDaO074916@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Dag-Erling=20Sm=C3=B8rgrav?= Subject: git: b03311cadd3a - main - renice: Avoid segfault if -n flag is given without argument. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b03311cadd3a6f931e176f97b97bd72be3ef96d4 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=b03311cadd3a6f931e176f97b97bd72be3ef96d4 commit b03311cadd3a6f931e176f97b97bd72be3ef96d4 Author: Dag-Erling Smørgrav AuthorDate: 2023-04-17 19:49:13 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2023-04-17 19:50:19 +0000 renice: Avoid segfault if -n flag is given without argument. Fixes: 65ee0a8495538 MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D39623 --- usr.bin/renice/renice.c | 2 +- usr.bin/renice/tests/renice_test.sh | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/usr.bin/renice/renice.c b/usr.bin/renice/renice.c index 890d7043ebbd..42e93cce240e 100644 --- a/usr.bin/renice/renice.c +++ b/usr.bin/renice/renice.c @@ -94,7 +94,7 @@ main(int argc, char *argv[]) } if (strcmp(*argv, "-n") == 0) { /* may occur only once, prior to priority */ - if (haveprio || incr) + if (haveprio || incr || argc < 2) usage(); incr = true; (void)argc--, argv++; diff --git a/usr.bin/renice/tests/renice_test.sh b/usr.bin/renice/tests/renice_test.sh index 9321e0f327ae..a6e8007ba35d 100644 --- a/usr.bin/renice/tests/renice_test.sh +++ b/usr.bin/renice/tests/renice_test.sh @@ -158,6 +158,11 @@ renice_delim_body() { kill $pid } +atf_test_case renice_incr_noarg +renice_incr_noarg_body() { + atf_check -o empty -e ignore -s exit:1 renice -n +} + atf_init_test_cases() { atf_add_test_case renice_abs_pid atf_add_test_case renice_rel_pid @@ -166,4 +171,5 @@ atf_init_test_cases() { atf_add_test_case renice_abs_user atf_add_test_case renice_rel_user atf_add_test_case renice_delim + atf_add_test_case renice_incr_noarg }