summaryrefslogtreecommitdiffstats
path: root/application-model
diff options
context:
space:
mode:
authorjonmv <venstad@gmail.com>2023-01-10 19:54:51 +0100
committerjonmv <venstad@gmail.com>2023-01-10 19:54:51 +0100
commitc0a84ecc6ff4d5fd5df9c4816d5bd91546a6ed4d (patch)
tree06219851de6c349a75eb86b0ae8dc970dac0cc9e /application-model
parent14254222b9540281f11b1c5dcf3e1fe102de390a (diff)
Do not trust user CRC32s in app package comparison for equality
Diffstat (limited to 'application-model')
-rw-r--r--application-model/src/main/java/com/yahoo/vespa/archive/ArchiveStreamReader.java23
1 files changed, 2 insertions, 21 deletions
diff --git a/application-model/src/main/java/com/yahoo/vespa/archive/ArchiveStreamReader.java b/application-model/src/main/java/com/yahoo/vespa/archive/ArchiveStreamReader.java
index 87665efc1ef..acc18b4c13f 100644
--- a/application-model/src/main/java/com/yahoo/vespa/archive/ArchiveStreamReader.java
+++ b/application-model/src/main/java/com/yahoo/vespa/archive/ArchiveStreamReader.java
@@ -74,7 +74,7 @@ public class ArchiveStreamReader implements AutoCloseable {
outputStream.write(buffer, 0, read);
}
}
- return new ArchiveFile(path, crc32(entry), size);
+ return new ArchiveFile(path, size);
}
} catch (IOException e) {
throw new UncheckedIOException(e);
@@ -91,15 +91,10 @@ public class ArchiveStreamReader implements AutoCloseable {
public static class ArchiveFile {
private final Path path;
- private final OptionalLong crc32;
private final long size;
- public ArchiveFile(Path name, OptionalLong crc32, long size) {
+ public ArchiveFile(Path name, long size) {
this.path = Objects.requireNonNull(name);
- this.crc32 = Objects.requireNonNull(crc32);
- if (crc32.isPresent()) {
- requireNonNegative("crc32", crc32.getAsLong());
- }
this.size = requireNonNegative("size", size);
}
@@ -108,11 +103,6 @@ public class ArchiveStreamReader implements AutoCloseable {
return path;
}
- /** The CRC-32 checksum of this file, if any */
- public OptionalLong crc32() {
- return crc32;
- }
-
/** The decompressed size of this file */
public long size() {
return size;
@@ -120,15 +110,6 @@ public class ArchiveStreamReader implements AutoCloseable {
}
- /** Get the CRC-32 checksum of given archive entry, if any */
- private static OptionalLong crc32(ArchiveEntry entry) {
- long crc32 = -1;
- if (entry instanceof ZipArchiveEntry) {
- crc32 = ((ZipArchiveEntry) entry).getCrc();
- }
- return crc32 > -1 ? OptionalLong.of(crc32) : OptionalLong.empty();
- }
-
private static boolean isSymlink(ArchiveEntry entry) {
// Symlinks inside ZIP files are not part of the ZIP spec and are only supported by some implementations, such
// as Info-ZIP.