Page MenuHomeFreeBSD

Fix off-by-one bug in btpand
ClosedPublic

Authored by dg612_cam.ac.uk on Jun 2 2024, 9:31 PM.
Tags
None
Referenced Files
Unknown Object (File)
Oct 3 2024, 11:03 PM
Unknown Object (File)
Oct 3 2024, 6:50 PM
Unknown Object (File)
Oct 1 2024, 7:38 PM
Unknown Object (File)
Oct 1 2024, 7:11 PM
Unknown Object (File)
Oct 1 2024, 5:41 PM
Unknown Object (File)
Oct 1 2024, 7:48 AM
Unknown Object (File)
Sep 30 2024, 4:21 PM
Unknown Object (File)
Sep 29 2024, 7:16 AM
Subscribers

Details

Summary

ul reaches __arraycount(services) before the bound-check happens, causing undefined behaviour.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

dg612_cam.ac.uk created this revision.

Please follow the wiki instructions and be sure to upload full context: https://wiki.freebsd.org/Phabricator#Create_a_Revision_via_Web_Interface

usr.sbin/bluetooth/btpand/btpand.c
146–151

Better as:

			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);

or similar, IMO, as a standard idiom

The update looks good to my eyes

This revision is now accepted and ready to land.Jun 3 2024, 2:38 PM
This revision was automatically updated to reflect the committed changes.