Validate values read from the RTC before trying BCD decoding

Submitted by:	cem
Reported by:	Michael Gmelin <freebsd@grem.de>
Tested by:	Oleksandr Tymoshenko <gonzo@bluezbox.com>
Sponsored by:	Dell EMC
This commit is contained in:
Eric van Gyzen 2017-03-09 02:19:30 +00:00
parent ad33b77611
commit 38ef0279a4

View File

@ -102,7 +102,12 @@ writertc(int reg, u_char val)
static __inline int
readrtc(int port)
{
return(bcd2bin(rtcin(port)));
int readval;
readval = rtcin(port);
if (readval >= 0 && (readval & 0xf) < 0xa && (readval & 0xf0) < 0xa0)
return (bcd2bin(readval));
return (0);
}
static void