changeset 12500:022d45d94d0a

8132652: Java_sun_nio_ch_Net_poll passes a long to an int Summary: Clamp long timeout parameter to [-1,INT_MAX]. Reviewed-by: alanb
author bpb
date Mon, 03 Aug 2015 10:25:38 -0700
parents 77228d1afabb
children 17e5192c59ae 72058a0c1a3a
files src/java.base/unix/native/libnio/ch/Net.c
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/unix/native/libnio/ch/Net.c	Mon Aug 03 09:25:02 2015 +0800
+++ b/src/java.base/unix/native/libnio/ch/Net.c	Mon Aug 03 10:25:38 2015 -0700
@@ -29,6 +29,7 @@
 #include <string.h>
 #include <netinet/in.h>
 #include <netinet/tcp.h>
+#include <limits.h>
 
 #include "jni.h"
 #include "jni_util.h"
@@ -709,7 +710,12 @@
     int rv;
     pfd.fd = fdval(env, fdo);
     pfd.events = events;
-    rv = poll(&pfd, 1, timeout);
+    if (timeout < -1) {
+        timeout = -1;
+    } else if (timeout > INT_MAX) {
+        timeout = INT_MAX;
+    }
+    rv = poll(&pfd, 1, (int)timeout);
 
     if (rv >= 0) {
         return pfd.revents;