rdblue commented on code in PR #5544:
URL: https://github.com/apache/iceberg/pull/5544#discussion_r1676514642


##########
api/src/main/java/org/apache/iceberg/encryption/EncryptingFileIO.java:
##########
@@ -109,14 +111,19 @@ public InputFile newInputFile(ManifestFile manifest) {
     }
   }
 
-  public InputFile newDecryptingInputFile(String path, ByteBuffer buffer) {
-    return em.decrypt(wrap(io.newInputFile(path), buffer));
-  }
-
   public InputFile newDecryptingInputFile(String path, long length, ByteBuffer 
buffer) {
-    // TODO: is the length correct for the encrypted file? It may be the 
length of the plaintext
-    // stream
-    return em.decrypt(wrap(io.newInputFile(path, length), buffer));
+    Preconditions.checkArgument(
+        length > 0, "Cannot safely decrypt table metadata file because its 
size is not specified");
+
+    InputFile inputFile = io.newInputFile(path, length);
+
+    if (inputFile.getLength() != length) {

Review Comment:
   This should not call `inputFile.getLength` because it will either return the 
length passed in above and is useless (`newInputFile(path, length)`) or it will 
make a call to the underlying storage (needless HEAD request). Don't we already 
catch cases where the file has been truncated?
   
   Hm. I don't see a test in `TestGcmStreams` so we should probably add one 
that validates truncated streams specifically.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to