PDGGK opened a new pull request, #168:
URL: https://github.com/apache/iotdb-client-go/pull/168

   ### What
   Fix an off-by-one in the index bounds checks of `Tablet.SetValueAt` and 
`Tablet.GetValueAt`.
   
   ### Problem
   Both methods validate `columnIndex`/`rowIndex` before indexing the 
schema/value slices and return an `illegal argument` error for out-of-range 
indices. The guards used `columnIndex > len(t.measurementSchemas)` and 
`rowIndex > t.maxRowNumber`. Since `measurementSchemas`/`values` have length N 
and each value slice + `timestamps` are `make([]T, maxRowNumber)` (see 
`NewTablet`), the valid ranges are `0..N-1` and `0..maxRowNumber-1`. Using `>` 
lets the exact boundary index (`== len`, `== maxRowNumber`) escape the guard, 
after which `measurementSchemas[N]` / `values[...][maxRowNumber]` panics with 
`index out of range` instead of returning the intended error. (The existing 
out-of-range tests use `65535`, far past the boundary, so never exercised it.)
   
   ### Fix
   Change all four guards from `>` to `>=`.
   
   ### Tests
   Added exact-boundary regression cases (`columnIndex == len`, `rowIndex == 
maxRowNumber`, `wantErr: true`) to `TestTablet_SetValueAt` / `GetValueAt`; they 
panic before the fix and return an error after. `go test ./client/` passes; 
`gofmt`/`vet` clean.
   


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

Reply via email to