Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitff843fa

Browse files
committed
8240333: jmod incorrectly updates .jar and .jmod files during hashing
Reviewed-by: martin, alanb, lancea
1 parent128f083 commitff843fa

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

‎src/jdk.jlink/share/classes/jdk/tools/jmod/JmodOutputStream.java‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016,2020,Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -92,7 +92,20 @@ public void writeEntry(byte[] bytes, Section section, String path)
9292
* Writes the given entry to the given input stream.
9393
*/
9494
publicvoidwriteEntry(InputStreamin,Entrye)throwsIOException {
95-
zos.putNextEntry(e.zipEntry());
95+
ZipEntrye1 =e.zipEntry();
96+
// Only preserve attributes which won't change by
97+
// inflating and deflating the entry. See:
98+
// sun.tools.jar.Main.update()
99+
ZipEntrye2 =newZipEntry(e1.getName());
100+
e2.setMethod(e1.getMethod());
101+
e2.setTime(e1.getTime());
102+
e2.setComment(e1.getComment());
103+
e2.setExtra(e1.getExtra());
104+
if (e1.getMethod() ==ZipEntry.STORED) {
105+
e2.setSize(e1.getSize());
106+
e2.setCrc(e1.getCrc());
107+
}
108+
zos.putNextEntry(e2);
96109
zos.write(in.readAllBytes());
97110
zos.closeEntry();
98111
}

‎src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015,2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015,2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -987,6 +987,12 @@ private void updateModularJar(Path target, Path tempTarget,
987987
recordHashes(in,jos,moduleHashes);
988988
jos.closeEntry();
989989
}else {
990+
// Setting "compressedSize" to "-1" prevents an error
991+
// in ZipOutputStream.closeEntry() if the newly
992+
// deflated entry will have another size than the
993+
// original compressed entry. See:
994+
// ZipOutputStream.putNextEntry()/closeEntry()
995+
e.setCompressedSize(-1);
990996
jos.putNextEntry(e);
991997
jos.write(in.readAllBytes());
992998
jos.closeEntry();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp