Sanity check ptr for legal values so it is less likely

(but not impossible) to get stuck in an infinite loop.

Obtained from:	msmith@freebsd.org
This commit is contained in:
Matt Jacob 2001-01-01 16:49:31 +00:00
parent 5bbc321312
commit afd27fce94

View File

@ -379,6 +379,12 @@ pci_read_extcap(device_t pcib, pcicfgregs *cfg)
* Read capability entries.
*/
while (nextptr != 0) {
/* Sanity check */
if (nextptr > 255) {
printf("illegal PCI extended capability offset %d\n",
nextptr);
return;
}
/* Find the next entry */
ptr = nextptr;
nextptr = REG(ptr + 1, 1);