mirror of
https://github.com/corda/corda.git
synced 2025-01-08 14:03:06 +00:00
classpath-openjdk: Fix getZipFileEntry()
'addSlash' argument was incorrectly understood: it is supposed to add slash only on retry (see ZIP_GetEntry2() zip_util.c in OpenJDK).
This commit is contained in:
parent
394c5cacce
commit
97734af72d
@ -1576,6 +1576,10 @@ int64_t JNICALL
|
|||||||
|
|
||||||
ZipFile::Entry* find(ZipFile* file, const char* path, unsigned pathLength)
|
ZipFile::Entry* find(ZipFile* file, const char* path, unsigned pathLength)
|
||||||
{
|
{
|
||||||
|
if (pathLength > 0 && path[0] == '/') {
|
||||||
|
++path;
|
||||||
|
--pathLength;
|
||||||
|
}
|
||||||
unsigned i = hash(path) & (file->indexSize - 1);
|
unsigned i = hash(path) & (file->indexSize - 1);
|
||||||
for (ZipFile::Entry* e = file->index[i]; e; e = e->next) {
|
for (ZipFile::Entry* e = file->index[i]; e; e = e->next) {
|
||||||
const uint8_t* p = e->start;
|
const uint8_t* p = e->start;
|
||||||
@ -1601,13 +1605,17 @@ int64_t JNICALL
|
|||||||
memcpy(RUNTIME_ARRAY_BODY(p), path->body().begin(), path->length());
|
memcpy(RUNTIME_ARRAY_BODY(p), path->body().begin(), path->length());
|
||||||
RUNTIME_ARRAY_BODY(p)[path->length()] = 0;
|
RUNTIME_ARRAY_BODY(p)[path->length()] = 0;
|
||||||
replace('\\', '/', RUNTIME_ARRAY_BODY(p));
|
replace('\\', '/', RUNTIME_ARRAY_BODY(p));
|
||||||
if (addSlash) {
|
|
||||||
|
ZipFile::Entry *e = find(file, RUNTIME_ARRAY_BODY(p), path->length());
|
||||||
|
|
||||||
|
if (e == 0 and addSlash and RUNTIME_ARRAY_BODY(p)[path->length()] != '/') {
|
||||||
RUNTIME_ARRAY_BODY(p)[path->length()] = '/';
|
RUNTIME_ARRAY_BODY(p)[path->length()] = '/';
|
||||||
RUNTIME_ARRAY_BODY(p)[path->length() + 1] = 0;
|
RUNTIME_ARRAY_BODY(p)[path->length() + 1] = 0;
|
||||||
|
|
||||||
|
e = find(file, RUNTIME_ARRAY_BODY(p), path->length());
|
||||||
}
|
}
|
||||||
|
|
||||||
return reinterpret_cast<int64_t>(
|
return reinterpret_cast<int64_t>(e);
|
||||||
find(file, RUNTIME_ARRAY_BODY(p), path->length()));
|
|
||||||
} else {
|
} else {
|
||||||
int64_t entry
|
int64_t entry
|
||||||
= cast<GcLong>(t,
|
= cast<GcLong>(t,
|
||||||
|
Loading…
Reference in New Issue
Block a user