Skip to content

Commit e014b49

Browse files
authored
Allow index 0 for paginated TLV data (#469)
1 parent e51e8ff commit e014b49

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

gateway-messages/src/sp_impl.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ fn handle_mgs_request<H: SpHandler>(
764764
}
765765
MgsRequest::BulkIgnitionState { offset } => {
766766
handler.num_ignition_ports().and_then(|port_count| {
767-
if offset >= port_count {
767+
if offset >= port_count && offset != 0 {
768768
Err(SpError::RequestUnsupportedForComponent)
769769
} else {
770770
let iter = handler.bulk_ignition_state(offset)?;
@@ -782,7 +782,7 @@ fn handle_mgs_request<H: SpHandler>(
782782
.map(SpResponse::IgnitionLinkEvents),
783783
MgsRequest::BulkIgnitionLinkEvents { offset } => {
784784
handler.num_ignition_ports().and_then(|port_count| {
785-
if offset >= port_count {
785+
if offset >= port_count && offset != 0 {
786786
Err(SpError::RequestUnsupportedForComponent)
787787
} else {
788788
let iter = handler.bulk_ignition_link_events(offset)?;
@@ -851,8 +851,9 @@ fn handle_mgs_request<H: SpHandler>(
851851
.map(|()| SpResponse::ResetComponentTriggerAck),
852852
MgsRequest::Inventory { device_index } => {
853853
// If a caller asks for an index past our end, return an error
854+
// (but allow `device_index = 0` to get total device count)
854855
let total_devices = handler.num_devices();
855-
if device_index >= total_devices {
856+
if device_index >= total_devices && device_index != 0 {
856857
Err(SpError::RequestUnsupportedForComponent)
857858
} else {
858859
// We need to pack TLV-encoded device descriptions as our outgoing
@@ -877,7 +878,8 @@ fn handle_mgs_request<H: SpHandler>(
877878
MgsRequest::ComponentDetails { component, offset } => {
878879
handler.num_component_details(component).and_then(|total_items| {
879880
// If a caller asks for an index past our end, return an error
880-
if offset >= total_items {
881+
// (but allow `offset = 0` to get total item count)
882+
if offset >= total_items && offset != 0 {
881883
Err(SpError::RequestUnsupportedForComponent)
882884
} else {
883885
// We need to pack TLV-encoded component details as our

0 commit comments

Comments
 (0)