src/java.base/share/native/libzip/zip_util.c

Print this page

        

@@ -35,10 +35,11 @@
 #include <limits.h>
 #include <time.h>
 #include <ctype.h>
 #include <assert.h>
 
+#include "jdk_strerror.h"
 #include "jni.h"
 #include "jni_util.h"
 #include "jlong.h"
 #include "jvm.h"
 #include "io_util.h"

@@ -1436,10 +1437,11 @@
  */
 jboolean JNICALL
 ZIP_ReadEntry(jzfile *zip, jzentry *entry, unsigned char *buf, char *entryname)
 {
     char *msg;
+    char tmpbuf[1024];
 
     strcpy(entryname, entry->name);
     if (entry->csize == 0) {
         /* Entry is stored */
         jlong pos = 0;

@@ -1454,12 +1456,15 @@
             ZIP_Lock(zip);
             n = ZIP_Read(zip, entry, pos, buf, count);
             msg = zip->msg;
             ZIP_Unlock(zip);
             if (n == -1) {
-                jio_fprintf(stderr, "%s: %s\n", zip->name,
-                            msg != 0 ? msg : strerror(errno));
+                if (msg == 0) {
+                    jdk_strerror(errno, tmpbuf, (size_t) 1024);
+                    msg = tmpbuf;
+                }
+                jio_fprintf(stderr, "%s: %s\n", zip->name, msg);
                 return JNI_FALSE;
             }
             buf += n;
             pos += n;
         }

@@ -1468,12 +1473,15 @@
         int ok = InflateFully(zip, entry, buf, &msg);
         if (!ok) {
             if ((msg == NULL) || (*msg == 0)) {
                 msg = zip->msg;
             }
-            jio_fprintf(stderr, "%s: %s\n", zip->name,
-                        msg != 0 ? msg : strerror(errno));
+            if (msg == 0) {
+                jdk_strerror(errno, tmpbuf, (size_t) 1024);
+                msg = tmpbuf;
+            }
+            jio_fprintf(stderr, "%s: %s\n", zip->name, msg);
             return JNI_FALSE;
         }
     }
 
     ZIP_FreeEntry(zip, entry);