Gargi-jais11 opened a new pull request, #11675:
URL: https://github.com/apache/ozone/pull/11675

   ## What changes were proposed in this pull request?
   `RangeHeaderParserUtil#parseRangeHeader` mishandles some edge-case Range 
values. Ozone returns **200 or 206** where AWS S3 returns 416 InvalidRange, and 
in two cases sends a malformed Content-Range header. The parser is shared, so 
this affects GetObject today and HeadObject once 
[HDDS-14224](https://issues.apache.org/jira/browse/HDDS-14224) is merged.
   
   Examples  -> suppose 10-byte object is created
   
   |```
   | Range     || Ozone                             || AWS S3 ||
   | bytes=10-   | 200, full object                   | 416 InvalidRange |
   | bytes=-0    | 206, Content-Range: bytes 10-9/10  | 416 InvalidRange |
   | bytes=-5 (empty object) | 206, Content-Range: bytes 0--1/0 | 416 
InvalidRange |
   | bytes=-    | 206, Content-Range: bytes 1-9/10 (drops byte 0) | 200, full 
object (header ignored) |
   ```
   For comparison, bytes=10-20 already returns 416 correctly.
   
   **Reason**
   An empty end is replaced with length-1 before the "end beyond object" check, 
so bytes=10- is never marked invalid. Suffix ranges are not checked for a zero 
suffix length, a zero-length object, or a missing suffix value.
   
   Found while reviewing 
[HDDS-14224](https://issues.apache.org/jira/browse/HDDS-14224) (PR 
https://github.com/apache/ozone/pull/11612)*
   
   ## What is the link to the Apache JIRA
   
   https://issues.apache.org/jira/browse/HDDS-17141
   
   ## How was this patch tested?
   
   Added unit tests and integration test.
   Done manual testing with this patch and taking changes from 
https://github.com/apache/ozone/pull/11612 :
   **Before**
   ```
   bash-5.1$ for op in get head; do
     rt $op ten   'bytes=10-'    # expect AWS: 416
     rt $op ten   'bytes=-0'     # expect AWS: 416
     rt $op empty 'bytes=-5'     # expect AWS: 416
     rt $op ten   'bytes=-'      # expect AWS: 200 full object
     rt $op ten   'bytes=10-20'  # control: 416 in both Ozone and AWS
     rt $op ten   'bytes=0-4'    # control: 206 "bytes 0-4/10", body 01234
     echo ---
   done
   get ten 'bytes=10-' -> status=200 len/range=[10 None] body='0123456789'
   get ten 'bytes=-0' -> status=206 len/range=[0   bytes 10-9/10] body=''
   get empty 'bytes=-5' -> status=206 len/range=[0 bytes 0--1/0] body=''
   get ten 'bytes=-' -> status=206 len/range=[9    bytes 1-9/10] 
body='123456789'
   get ten 'bytes=10-20' -> status=416 len/range=[] body='123456789' 
(InvalidRange)
   get ten 'bytes=0-4' -> status=206 len/range=[5  bytes 0-4/10] body='01234'
   ---
   head ten 'bytes=10-' -> status=200 len/range=[10        None]
   head ten 'bytes=-0' -> status=200 len/range=[10 None]
   head empty 'bytes=-5' -> status=200 len/range=[0        None]
   head ten 'bytes=-' -> status=200 len/range=[10  None]
   head ten 'bytes=10-20' -> status=200 len/range=[10      None]
   head ten 'bytes=0-4' -> status=200 len/range=[10        None]
   ---
   ```
   **After**
   ```
   get ten 'bytes=10-' -> status=416 len/range=[] body='' 
wire-Content-Range=none Accept-Ranges=none (InvalidRange)
   get ten 'bytes=-0' -> status=416 len/range=[] body='' 
wire-Content-Range=none Accept-Ranges=none (InvalidRange)
   get empty 'bytes=-5' -> status=416 len/range=[] body='' 
wire-Content-Range=none Accept-Ranges=none (InvalidRange)
   get ten 'bytes=-' -> status=200 len/range=[10   None] body='0123456789' 
wire-Content-Range=none Accept-Ranges=bytes
   get ten 'bytes=10-20' -> status=416 len/range=[] body='' 
wire-Content-Range=none Accept-Ranges=none (InvalidRange)
   get ten 'bytes=0-4' -> status=206 len/range=[5  bytes 0-4/10] body='01234' 
wire-Content-Range=bytes 0-4/10 Accept-Ranges=bytes
   ---
   head ten 'bytes=10-' -> status=416 len/range=[] wire-Content-Range=none 
Accept-Ranges=none
   head ten 'bytes=-0' -> status=416 len/range=[] wire-Content-Range=none 
Accept-Ranges=none
   head empty 'bytes=-5' -> status=416 len/range=[] wire-Content-Range=none 
Accept-Ranges=none
   head ten 'bytes=-' -> status=200 len/range=[10  None] 
wire-Content-Range=none Accept-Ranges=bytes
   head ten 'bytes=10-20' -> status=416 len/range=[] wire-Content-Range=none 
Accept-Ranges=none
   head ten 'bytes=0-4' -> status=206 len/range=[5 None] 
wire-Content-Range=bytes 0-4/10 Accept-Ranges=bytes
   ---
   ```
   


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