You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2021/07/28 00:54:43 UTC

[GitHub] [ozone] smengcl commented on a change in pull request #2463: HDDS-5483.Validate block file length during put block

smengcl commented on a change in pull request #2463:
URL: https://github.com/apache/ozone/pull/2463#discussion_r677896200



##########
File path: hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueHandler.java
##########
@@ -427,6 +429,17 @@ ContainerCommandResponseProto handlePutBlock(
       ContainerProtos.BlockData data = request.getPutBlock().getBlockData();
       BlockData blockData = BlockData.getFromProtoBuf(data);
       Preconditions.checkNotNull(blockData);
+      ChunkLayOutVersion layoutVersion =
+          ChunkLayOutVersion.getConfiguredVersion(conf);
+      if (layoutVersion == FILE_PER_BLOCK) {
+        File blockFile = layoutVersion
+            .getChunkFile(kvContainer.getContainerData(),
+                blockData.getBlockID(), null);
+        // ensure that the putBlock length <= blockFile length
+        Preconditions.checkArgument(blockFile.length() >= blockData.getSize(),

Review comment:
       Under what conditions could this be violated?




-- 
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-unsubscribe@ozone.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org