Skip to content

Commit

Permalink
Merge pull request #156 from jr-oss/rust_regreesion_buffer_size
Browse files Browse the repository at this point in the history
Fix regression in Rust binding. Commit 51b626c
  • Loading branch information
sidcha committed Jan 14, 2024
2 parents 4394508 + 6a5579c commit 9eea249
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions rust/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ impl From<libosdp_sys::osdp_cmd_text> for OsdpCommandText {

impl From<OsdpCommandText> for libosdp_sys::osdp_cmd_text {
fn from(value: OsdpCommandText) -> Self {
let mut data: [u8; 32] = [0; 32];
let mut data = [0; libosdp_sys::OSDP_CMD_TEXT_MAX_LEN as usize];
for i in 0..value.data.len() {
data[i] = value.data[i];
}
Expand Down Expand Up @@ -407,7 +407,7 @@ impl From<libosdp_sys::osdp_cmd_keyset> for OsdpCommandKeyset {

impl From<OsdpCommandKeyset> for libosdp_sys::osdp_cmd_keyset {
fn from(value: OsdpCommandKeyset) -> Self {
let mut data: [u8; 32] = [0; 32];
let mut data = [0; libosdp_sys::OSDP_CMD_KEYSET_KEY_MAX_LEN as usize];
for i in 0..value.data.len() {
data[i] = value.data[i];
}
Expand Down Expand Up @@ -448,7 +448,7 @@ impl From<libosdp_sys::osdp_cmd_mfg> for OsdpCommandMfg {

impl From<OsdpCommandMfg> for libosdp_sys::osdp_cmd_mfg {
fn from(value: OsdpCommandMfg) -> Self {
let mut data: [u8; 64] = [0; 64];
let mut data = [0; libosdp_sys::OSDP_CMD_MFG_MAX_DATALEN as usize];
for i in 0..value.data.len() {
data[i] = value.data[i];
}
Expand Down
6 changes: 3 additions & 3 deletions rust/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl From<libosdp_sys::osdp_event_cardread> for OsdpEventCardRead {

impl From<OsdpEventCardRead> for libosdp_sys::osdp_event_cardread {
fn from(value: OsdpEventCardRead) -> Self {
let mut data: [u8; 64] = [0; 64];
let mut data = [0; libosdp_sys::OSDP_EVENT_CARDREAD_MAX_DATALEN as usize];
let length = match value.format {
OsdpCardFormats::Weigand => value.nr_bits as i32,
_ => value.data.len() as i32,
Expand Down Expand Up @@ -185,7 +185,7 @@ impl From<libosdp_sys::osdp_event_keypress> for OsdpEventKeyPress {

impl From<OsdpEventKeyPress> for libosdp_sys::osdp_event_keypress {
fn from(value: OsdpEventKeyPress) -> Self {
let mut data: [u8; 64] = [0; 64];
let mut data = [0; libosdp_sys::OSDP_EVENT_KEYPRESS_MAX_DATALEN as usize];
for i in 0..value.data.len() {
data[i] = value.data[i];
}
Expand Down Expand Up @@ -226,7 +226,7 @@ impl From<libosdp_sys::osdp_event_mfgrep> for OsdpEventMfgReply {

impl From<OsdpEventMfgReply> for libosdp_sys::osdp_event_mfgrep {
fn from(value: OsdpEventMfgReply) -> Self {
let mut data: [u8; 64] = [0; 64];
let mut data = [0; libosdp_sys::OSDP_EVENT_MFGREP_MAX_DATALEN as usize];
for i in 0..value.data.len() {
data[i] = value.data[i];
}
Expand Down

0 comments on commit 9eea249

Please sign in to comment.