Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid byte order on single entry get in Counter, Meter and Register #88

Merged
merged 1 commit into from
Jan 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/nikss_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@ static int read_and_parse_counter_value(nikss_counter_context_t *ctx, nikss_coun
return ret;
}

/* raw_key is always used as a data source for user request on next field, so convert it to right byte order */
fix_struct_data_byte_order(&ctx->key_fds, entry->raw_key, ctx->counter.key_size);

return convert_counter_data_to_entry(value, ctx->counter.value_size, ctx->counter_type, entry);
}

Expand Down Expand Up @@ -360,8 +363,6 @@ nikss_counter_entry_t *nikss_counter_get_next(nikss_counter_context_t *ctx)
return NULL;
}

fix_struct_data_byte_order(&ctx->key_fds, ctx->current_entry.raw_key, ctx->counter.key_size);

return &ctx->current_entry;
}

Expand Down
3 changes: 3 additions & 0 deletions lib/nikss_meter.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,9 @@ int nikss_meter_entry_get(nikss_meter_ctx_t *ctx, nikss_meter_entry_t *entry)
goto clean_up;
}

/* Later raw_index is used instead of user provided data, so fix its byte order */
fix_struct_data_byte_order(&ctx->index_fds, entry->raw_index, ctx->meter.key_size);

nikss_meter_data_t data;
memcpy(&data, value_buffer, sizeof(data));
return_code = convert_meter_data_to_entry(&data, entry);
Expand Down
3 changes: 2 additions & 1 deletion lib/nikss_register.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,8 @@ int nikss_register_get(nikss_register_context_t *ctx, nikss_register_entry_t *en
return ret;
}

fix_struct_data_byte_order(&ctx->value_fds, ctx->current_entry.raw_value, ctx->reg.value_size);
fix_struct_data_byte_order(&ctx->value_fds, entry->raw_key, ctx->reg.key_size);
fix_struct_data_byte_order(&ctx->value_fds, entry->raw_value, ctx->reg.value_size);

return NO_ERROR;
}
Expand Down