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
--- a/jdk/src/java.base/unix/native/libnio/ch/Net.c Mon Aug 03 09:25:02 2015 +0800
+++ b/jdk/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;