src/java.base/share/native/libzip/zip_util.c
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File
*** old/src/java.base/share/native/libzip/zip_util.c	Mon Sep 10 10:42:58 2018
--- new/src/java.base/share/native/libzip/zip_util.c	Mon Sep 10 10:42:58 2018

*** 98,107 **** --- 98,110 ---- * need to concern ourselves with wide chars. */ static ZFILE ZFILE_Open(const char *fname, int flags) { #ifdef WIN32 + WCHAR *wfname, *wprefixed_fname; + size_t converted_chars, fname_length; + jlong fhandle; const DWORD access = (flags & O_RDWR) ? (GENERIC_WRITE | GENERIC_READ) : (flags & O_WRONLY) ? GENERIC_WRITE : GENERIC_READ; const DWORD sharing =
*** 119,136 **** --- 122,162 ---- (flags & O_TEMPORARY) ? FILE_FLAG_DELETE_ON_CLOSE : FILE_ATTRIBUTE_NORMAL; const DWORD flagsAndAttributes = maybeWriteThrough | maybeDeleteOnClose; return (jlong) CreateFile( fname, /* Wide char path name */ + fname_length = strlen(fname); + if (fname_length < MAX_PATH) { + return (jlong)CreateFile( + fname, /* Ascii char path name */ access, /* Read and/or write permission */ sharing, /* File sharing flags */ NULL, /* Security attributes */ disposition, /* creation disposition */ flagsAndAttributes, /* flags and attributes */ NULL); + } else { + if ((wfname = (WCHAR*)malloc((fname_length + 1) * sizeof(WCHAR))) == NULL) + return (jlong)INVALID_HANDLE_VALUE; + + if (mbstowcs_s(&converted_chars, wfname, fname_length + 1, fname, fname_length) != 0) { + free(wfname); + return (jlong)INVALID_HANDLE_VALUE; + } + wprefixed_fname = getPrefixed(wfname, (int)fname_length); + fhandle = (jlong)CreateFileW( + wprefixed_fname, /* Wide char path name */ + access, /* Read and/or write permission */ + sharing, /* File sharing flags */ + NULL, /* Security attributes */ + disposition, /* creation disposition */ + flagsAndAttributes, /* flags and attributes */ + NULL); + free(wfname); + free(wprefixed_fname); + return fhandle; + } #else return open(fname, flags, 0); #endif }

src/java.base/share/native/libzip/zip_util.c
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File