diff --git a/usr.sbin/bluetooth/btpand/btpand.c b/usr.sbin/bluetooth/btpand/btpand.c --- a/usr.sbin/bluetooth/btpand/btpand.c +++ b/usr.sbin/bluetooth/btpand/btpand.c @@ -143,11 +143,14 @@ 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;