src/java.base/windows/native/libnet/TwoStacksPlainDatagramSocketImpl.c

Print this page

        

@@ -43,10 +43,11 @@
 #include "java_net_SocketOptions.h"
 #include "java_net_NetworkInterface.h"
 
 #include "NetworkInterface.h"
 #include "jvm.h"
+#include "jdk_strerror.h"
 #include "jni_util.h"
 #include "net_util.h"
 
 #define IN_CLASSD(i)    (((long)(i) & 0xf0000000) == 0xe0000000)
 #define IN_MULTICAST(i) IN_CLASSD(i)

@@ -2166,10 +2167,11 @@
 Java_java_net_TwoStacksPlainDatagramSocketImpl_socketGetOption(JNIEnv *env, jobject this,
                                                       jint opt) {
 
     int fd=-1, fd1=-1;
     int level, optname, optlen;
+    char buf[1024];
     union {
         int i;
     } optval = {0};
     int ipv6_supported = ipv6_available();
 

@@ -2209,12 +2211,14 @@
         fd = fd1; /* must be IPv6 only */
     }
 
     optlen = sizeof(optval.i);
     if (NET_GetSockOpt(fd, level, optname, (void *)&optval, &optlen) < 0) {
-        char errmsg[255];
-        sprintf(errmsg, "error getting socket option: %s\n", strerror(errno));
+        int size = 0;
+        char errmsg[300];
+        jdk_strerror(errno, buf, (size_t) 255);
+        sprintf(errmsg, "error getting socket option: %s\n", buf);
         JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", errmsg);
         return NULL;
     }
 
     switch (opt) {