From nobody Sat Sep 07 01:48:05 2024 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 4X0wwP2Nkrz5WSP1; Sat, 07 Sep 2024 01:48:05 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4X0wwP1jLZz4k88; Sat, 7 Sep 2024 01:48:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725673685; 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=jVQmx1+PGLbhHZpk0hZd6ht3vxIeO3i7zaSpRM4tPWM=; b=Rm9BgeK31eFfr4ukRsmsbE/vA+n/kFb43INJufZexYMdoKXxMXJJnFEJMZzlT+PScpI3bC ODNBzn18yDCpQ0pz5XL+pJB1qM9dDLJtfkyPwEpFdSc3KALIiIdsrO2iJgbwJESIbe1DV9 Jd5JH4nlKGRLyoeLRaVoVyQsf/H58q2fnidNyknaHbZR+xoU/qtyHEzek4vrsyJSuj8Xgp vXXqKsTSpCNHNQAC4xp9LQlhHcVCK/cYG1ha8e113Mi0LxK8nzhLSY1FRm4GnUTvRhllHY Qqum9brdWC6Dm40LSoA25En32iXTjeGI+8QlXhb79/Df3UACgm8brIFng/bu5g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725673685; a=rsa-sha256; cv=none; b=d6c2tzysIp7tQrAAmnbLEGbcXPQeBkW4Bv4EG0O/RTnQGhdLfYAV8Tmv10Zb6mRzqIdqJO 0TDi2tR/iCC9EbbQA34ykurcr/W9/IE64bVhgsC848y2ZTxnlHSb9MYPIgfLz5ntmWSPLX E4daNhFwqie1kHjn46/85tp6XpvRsaxAVm6yrsjjuRSh9btzetMOMhObXooWR//wNE/pBD Xy37DqoPmY1bYUOJMViI7iwWaJs3PJZnaS7/IwFFNgTFfFe6JIUlc5j8xm3AS6bJqf28Fd 2LJ7molZc23kIZ0pK8cSEGl+DtrynSeqOZ6l2MqibUrJmHBgp1RO9qpCRHMNDw== 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=1725673685; 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=jVQmx1+PGLbhHZpk0hZd6ht3vxIeO3i7zaSpRM4tPWM=; b=cDljiYi/7X6sMKNOBDAlPraFT6ktVfxE23KnutE5cRFyMQpd4EcKsOAgndsfms4GgN7BqJ fBaJq6vV/Z+f+GFUAMTwfOmEkgx9kFnNkw2Dtr2rbZGhT2RrfHtG/af9HYLBVb+84EsBJ+ GTcMUxZCQnQb2OPuYWvL0yUT1zHJBgGb5kJsOsMvJctXkJKhFm79z0W0MI+c4wLIu/fXeR gkT4DAb61+KYWcdmhZWoVqmTpU6EnvVl9lMTp6wBG6FZp+9m0bs6En0d3i9TZKpoD9HH6o tRJNj8orZ9p9AMbHn9EzdQGjmWDoyRklQWTJyUu8Z99ldexo7VCEBnksQLi0Cw== 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 4X0wwP1JWxzGPf; Sat, 7 Sep 2024 01:48:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4871m5b6041975; Sat, 7 Sep 2024 01:48:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4871m5vn041972; Sat, 7 Sep 2024 01:48:05 GMT (envelope-from git) Date: Sat, 7 Sep 2024 01:48:05 GMT Message-Id: <202409070148.4871m5vn041972@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Jessica Clarke Subject: git: ebdd179d759f - stable/14 - Fix off-by-one bug in btpand 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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/stable/14 X-Git-Reftype: branch X-Git-Commit: ebdd179d759f29354a0998c0308721a551a08cac Auto-Submitted: auto-generated The branch stable/14 has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=ebdd179d759f29354a0998c0308721a551a08cac commit ebdd179d759f29354a0998c0308721a551a08cac Author: Dapeng Gao AuthorDate: 2024-06-03 19:30:36 +0000 Commit: Jessica Clarke CommitDate: 2024-09-07 00:01:11 +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 (cherry picked from commit fbfdf57d65bedfab28f9debc8a4a8d6802f9338a) --- 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 0d2eece68747..b8f6a1d4c8d1 100644 --- a/usr.sbin/bluetooth/btpand/btpand.c +++ b/usr.sbin/bluetooth/btpand/btpand.c @@ -147,11 +147,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;