chungen0126 opened a new pull request, #11693:
URL: https://github.com/apache/ozone/pull/11693

   ## What changes were proposed in this pull request?
   
   `RANGE_HEADER_MATCH_PATTERN` accepts digit strings of any length, and both 
`RangeHeaderParserUtil#parseRangeHeader`
   (GetObject, HeadObject) and the UploadPartCopy path in `ObjectEndpoint` pass 
them to `Long.parseLong`. A byte position
   larger than `Long.MAX_VALUE`, e.g. `Range: bytes=0-99999999999999999999`, 
throws `NumberFormatException`. No exception
   mapper handles it, so the client gets a 500 Internal Error.
   
   This PR treats such a position as a malformed range, the same as a value 
that does not match the pattern:
   - GetObject / HeadObject ignore the `Range` header and return the whole 
object with 200.
   - UploadPartCopy rejects the `x-amz-copy-source-range` with 400 
`InvalidArgument`.
   
   This matches Amazon S3. Results from a real S3 bucket with a 10-byte object:
   
   | Range | GetObject | HeadObject |
   |---|---|---|
   | `bytes=0-9223372036854775807` (`Long.MAX_VALUE`) | 206, `bytes 0-9/10` | 
206 |
   | `bytes=0-9223372036854775808` (`Long.MAX_VALUE + 1`) | 200, whole object | 
200 |
   | `bytes=0-99999999999999999999` | 200, whole object | 200 |
   | `bytes=99999999999999999999-`, `bytes=-99999999999999999999` | 200, whole 
object | 200 |
   
   | x-amz-copy-source-range | UploadPartCopy |
   |---|---|
   | `bytes=0-9223372036854775808`, `bytes=0-99999999999999999999` | 400 
`InvalidArgument` ("The x-amz-copy-source-range value must be of the form 
bytes=first-last ...") |
   
   S3 parses positions up to `Long.MAX_VALUE` as numbers and treats anything 
larger as malformed, so catching
   `NumberFormatException` gives the same boundary.
   
   ## What is the link to the Apache JIRA
   
   https://issues.apache.org/jira/browse/HDDS-17306
   
   ## How was this patch tested?
   
   - Added unit tests in `TestRangeHeaderParserUtil`, `TestObjectGet`, 
`TestObjectHead` and `TestMultipartUploadWithCopy`
     for byte positions at and above `Long.MAX_VALUE`, following the S3 results 
above. Without the fix, the overflow
     cases fail with `NumberFormatException`.
   - All `ozone-s3gateway` unit tests pass, and checkstyle is clean.
   
   Generated-by: Claude Code (Claude Opus 5.5)
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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]

Reply via email to