Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 9 Mar 2017 02:19:30 +0000 (UTC)
From:      Eric van Gyzen <vangyzen@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r314936 - head/sys/x86/isa
Message-ID:  <201703090219.v292JUDS085429@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: vangyzen
Date: Thu Mar  9 02:19:30 2017
New Revision: 314936
URL: https://svnweb.freebsd.org/changeset/base/314936

Log:
  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

Modified:
  head/sys/x86/isa/atrtc.c

Modified: head/sys/x86/isa/atrtc.c
==============================================================================
--- head/sys/x86/isa/atrtc.c	Thu Mar  9 01:26:10 2017	(r314935)
+++ head/sys/x86/isa/atrtc.c	Thu Mar  9 02:19:30 2017	(r314936)
@@ -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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703090219.v292JUDS085429>