From nobody Mon Jun 03 19:31:02 2024 X-Original-To: dev-commits-src-main@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 4VtP3B3tTWz5JslW; Mon, 03 Jun 2024 19:31:02 +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 4VtP3B3NV2z4cVR; Mon, 3 Jun 2024 19:31:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1717443062; 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=e7tX937ptuh3lcgaAHQVKJzJHn/d6DeKk53lQc6i7d4=; b=CTnoKydGs+jNG0899sRYGGTuKcCnq7mXc/K+j8B7OhZjck8mYMpAH9yOCmeRJMYB80DQ+U kVI3Q17XbLddpNAPu7MnJNTxIeujwbcZsDq7s1uVQ0GkLflT4JArz7zBowTP+zBJaCTM5N W44VTASJwkOxbQimWmXNLNyhHMTdg17cwiNw/UkFKwuwFaja6YLy3ffsRZbkNXdrkRi46g lDQEeP0QBOeoyP3aaNKwEIi1cC6NmhrAMW2bKausmUp41nmAxz6Sa08F27N0P5ydbz041I SiEbdckIZ+gvFxryOZl1O/fpnknzGqvo4zsEQ5sFAxY33JRa6oGkUZ/YGmqfKg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1717443062; a=rsa-sha256; cv=none; b=XIHE8pxAqsPN7pfX1d/OZfIRKwrV/N32C3N85tapcBfLnrcqSARv/Us/XodleURZVGalDO 8cj5T8dXznf8nC/IiMaJyM16u925nlvvx00LEyB2jMofmu8/C1NN5dAOtuGfFen1djU2ZL CYGz43+bjN5MN/Q+Z3W7h1aophVztU4TL63sQVUPmuY6m3Ci0x2vEYzoXcwqMfjtpDfZX/ Z4Q1OZ6QvkJgBOle/S/pBOHwD0jY2I1RwcM/4Vt0GnhFTKJ3np5rWg8NyYR+hHYsaUwtb9 YTv9+SY4r4qpFFECO67U1tmPTLeIDw/J+o5UEc/erNgjbvDCNhCzldwnyGpNlw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1717443062; 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=e7tX937ptuh3lcgaAHQVKJzJHn/d6DeKk53lQc6i7d4=; b=e//ZqJx+dQSG3cJ7kywnqnG5YwqK+G54Bp/BH2Oe8m7oxTubX4GwNcTOTSwVlTGkF5yOQg GQdEdIZfL98nmjUvpDBgv+WNE4oOae6bNJN9EeuYD1HCWR4l2gCqviXyMPcUygi0H6RbbN hnMN+UtWD7SLVgh9P5dgpumaubZnuxUWzObCwjOdJxtIMfnYgvx27xou+JxNPxyjfWf6wD kMoZOu5hoSCPwRcyJeKOWpsQdl3jEM8J7PWTqE2Oq4vHrWwScDb8Xu+pPXgke8C9K8sGtP QLr93Lmil/6FlWOoxxC7Dck1m5Pt8uP0polotvFBASlaI/bEVFHjBQBuXKcRdQ== 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 4VtP3B2nMXznnQ; Mon, 3 Jun 2024 19:31:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 453JV2Eh081927; Mon, 3 Jun 2024 19:31:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 453JV2IM081924; Mon, 3 Jun 2024 19:31:02 GMT (envelope-from git) Date: Mon, 3 Jun 2024 19:31:02 GMT Message-Id: <202406031931.453JV2IM081924@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jessica Clarke Subject: git: fbfdf57d65be - main - Fix off-by-one bug in btpand List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jrtc27 X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fbfdf57d65bedfab28f9debc8a4a8d6802f9338a Auto-Submitted: auto-generated The branch main has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=fbfdf57d65bedfab28f9debc8a4a8d6802f9338a commit fbfdf57d65bedfab28f9debc8a4a8d6802f9338a Author: Dapeng Gao AuthorDate: 2024-06-03 19:30:36 +0000 Commit: Jessica Clarke CommitDate: 2024-06-03 19:30:36 +0000 Fix off-by-one bug in btpand `ul` reaches `__arraycount(services)` before the bound-check happens, causing undefined behaviour. Reviewed by: imp, jrtc27 Fixes: 7718ced0ea98 ("Add btpand(8) daemon from NetBSD.") MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D45463 --- usr.sbin/bluetooth/btpand/btpand.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/usr.sbin/bluetooth/btpand/btpand.c b/usr.sbin/bluetooth/btpand/btpand.c index d4bc15823290..f0b29837188f 100644 --- a/usr.sbin/bluetooth/btpand/btpand.c +++ b/usr.sbin/bluetooth/btpand/btpand.c @@ -143,11 +143,14 @@ main(int argc, char *argv[]) case 's': /* service */ case 'S': /* service (no SDP) */ - for (ul = 0; strcasecmp(optarg, services[ul].name); ul++) { - if (ul == __arraycount(services)) - errx(EXIT_FAILURE, "%s: unknown service", optarg); + for (ul = 0; ul < __arraycount(services); ul++) { + if (strcasecmp(optarg, services[ul].name) == 0) + break; } + if (ul == __arraycount(services)) + errx(EXIT_FAILURE, "%s: unknown service", optarg); + if (ch == 's') service_name = services[ul].name;