DF-5666 / fix.diff
--- a/sys/platform/pc64/x86_64/bios.c +++ b/sys/platform/pc64/x86_64/bios.c @@ -66,8 +66,14 @@ bios_sigsearch(u_int32_t start, u_char *sig, int siglen, int paralen, int sigofs) { u_char *sp, *end; + /* + * Sanity-check the scan parameters. A zero or negative paragraph + * step would loop forever or walk below the BIOS window, and a + * negative sigofs / non-positive siglen would read outside it. + */ + if (sig == NULL || siglen <= 0 || paralen <= 0 || sigofs < 0) + return 0; + /* compute the starting address */ if ((start >= BIOS_START) && (start <= (BIOS_START + BIOS_SIZE))) { sp = (char *)BIOS_PADDRTOVADDR(start); |