src/java.base/unix/native/libjava/jni_util_md.c

Print this page

        

@@ -24,10 +24,11 @@
  */
 
 #include <errno.h>
 #include <string.h>
 
+#include "jdk_strerror.h"
 #include "jni.h"
 #include "jni_util.h"
 #include "dlfcn.h"
 
 void* getProcessHandle() {

@@ -53,18 +54,19 @@
 }
 
 size_t
 getLastErrorString(char *buf, size_t len)
 {
-    char *err;
-    size_t n;
+    char tmpbuf[1024];
+    int n = 0;
+
     if (errno == 0 || len < 1) return 0;
 
-    err = strerror(errno);
-    n = strlen(err);
-    if (n >= len)
-        n = len - 1;
+    jdk_strerror(errno, tmpbuf, (size_t) 1024);
+    n = strlen(tmpbuf);
+    if (n >= (int) len)
+        n = (int) len - 1;
 
-    strncpy(buf, err, n);
+    strncpy(buf, tmpbuf, n);
     buf[n] = '\0';
     return n;
 }