changeset 52:30ca0cd2b8ba

8065577: Verify parameters for ModemSignalEvent Reviewed-by: snazarki Contributed-by: alexey.mironov@oracle.com
author snazarki
date Fri, 21 Nov 2014 19:10:52 +0400
parents 950002a54da8
children 8a38ebab04a0
files src/share/classes/jdk/dio/modem/ModemSignalEvent.java
diffstat 1 files changed, 10 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/jdk/dio/modem/ModemSignalEvent.java	Tue Oct 14 17:29:24 2014 -0400
+++ b/src/share/classes/jdk/dio/modem/ModemSignalEvent.java	Fri Nov 21 19:10:52 2014 +0400
@@ -97,6 +97,16 @@
         this.timeStamp = timeStamp;
         this.timeStampMicros = timeStampMicros;
         this.count = 1;
+
+        // null check
+        device.getClass();
+
+        final int mask = (ModemSignalsControl.DCD_SIGNAL | ModemSignalsControl.DSR_SIGNAL |
+                          ModemSignalsControl.RI_SIGNAL   | ModemSignalsControl.CTS_SIGNAL);
+        if (signalID == 0 || (~mask & signalID) != 0 ||
+            0 > timeStamp || 0 > timeStampMicros) {
+            throw new IllegalArgumentException();
+        }
     }
 
     void addOccurence(boolean signalState, long timeStamp) {