szetszwo commented on code in PR #10347:
URL: https://github.com/apache/ozone/pull/10347#discussion_r3293251761
##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmMultipartPartKey.java:
##########
@@ -184,7 +186,14 @@ private OmMultipartPartKey fromByteBuffer(ByteBuffer
rawData)
final ByteBuffer uploadIdBuffer = input.duplicate();
uploadIdBuffer.limit(separatorIndex);
uploadIdBuffer.position(start);
- String uploadId =
StandardCharsets.UTF_8.decode(uploadIdBuffer).toString();
+ byte[] uploadIdBytes = new byte[uploadIdBuffer.remaining()];
+ uploadIdBuffer.get(uploadIdBytes);
+ String uploadId = StringCodec.get().fromPersistedFormat(uploadIdBytes);
+ if (!Arrays.equals(uploadIdBytes,
+ uploadId.getBytes(StandardCharsets.UTF_8))) {
+ throw new IllegalArgumentException(
+ "Invalid multipart part key: malformed UTF-8 uploadId");
+ }
Review Comment:
@Russole , thanks for working on this! We should throw CodecException. It
needs a new variant of StringCodec. Filed HDDS-15355.
BTW, we should also change the other IllegalArgumentException in
OmMultipartPartKeyCodec to CodecException.
##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmMultipartPartKey.java:
##########
@@ -184,7 +186,14 @@ private OmMultipartPartKey fromByteBuffer(ByteBuffer
rawData)
final ByteBuffer uploadIdBuffer = input.duplicate();
uploadIdBuffer.limit(separatorIndex);
uploadIdBuffer.position(start);
- String uploadId =
StandardCharsets.UTF_8.decode(uploadIdBuffer).toString();
+ byte[] uploadIdBytes = new byte[uploadIdBuffer.remaining()];
+ uploadIdBuffer.get(uploadIdBytes);
+ String uploadId = StringCodec.get().fromPersistedFormat(uploadIdBytes);
+ if (!Arrays.equals(uploadIdBytes,
+ uploadId.getBytes(StandardCharsets.UTF_8))) {
+ throw new IllegalArgumentException(
+ "Invalid multipart part key: malformed UTF-8 uploadId");
+ }
Review Comment:
@Russole , thanks for working on this! We should throw CodecException. It
needs a new variant of StringCodec. Filed HDDS-15355.
BTW, we should also change the other IllegalArgumentException in
OmMultipartPartKeyCodec to CodecException.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]