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

Fix #117: Allow incorrectly encoded alignment bits #118

Merged
merged 1 commit into from
May 7, 2024
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
1 change: 1 addition & 0 deletions asn-compiler/src/parser/asn/structs/types/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#[derive(Debug, Clone)]
pub(crate) enum NamedValue {
Number(String),
#[allow(dead_code)]
ValueRef(String),
}

Expand Down
14 changes: 12 additions & 2 deletions codecs/src/per/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,24 @@ impl PerCodecData {
.iter()
.all(|b| b == false)
{
Err(PerCodecError::new(
// Issue 117: Sometimes the sender doesn't send the bits correctly.
// Accept it but log.
log::warn!(
"{} Padding bits {} at Offset {} not all '0'",
remaining,
&self.bits[self.decode_offset..self.decode_offset + remaining],
self.decode_offset
);
self.decode_offset += remaining;
Ok(())
/* Err(PerCodecError::new(
PerCodecErrorCause::InvalidAlignment,
format!(
"{} Padding bits at Offset {} not all '0'.",
remaining, self.decode_offset,
)
.as_str(),
))
)) */
} else {
self.decode_offset += remaining;
Ok(())
Expand Down
11 changes: 11 additions & 0 deletions examples/tests/13-ngap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,15 @@ fn main() {
let mut codec_data = PerCodecData::from_slice_aper(&response_data);
let ngap_pdu = ngap::NGAP_PDU::aper_decode(&mut codec_data);
eprintln!("ngap_pdu: {:?}", ngap_pdu);

let issue_117_data: [u8; 57] = [
0x00, 0x15, 0x00, 0x35, 0x00, 0x00, 0x04, 0x00, 0x1b, 0x00, 0x08, 0x00, 0x02, 0xf8, 0x39,
0x03, 0x80, 0x00, 0x04, 0x00, 0x52, 0x40, 0x09, 0x03, 0x00, 0x4e, 0x65, 0x72, 0x76, 0x69,
0x6f, 0x6e, 0x00, 0x66, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0xf8, 0x39,
0x00, 0x00, 0x10, 0x08, 0x00, 0x00, 0x01, 0x00, 0x15, 0x40, 0x01, 0x40,
];

let mut codec_data = PerCodecData::from_slice_aper(&issue_117_data);
let ngap_pdu = ngap::NGAP_PDU::aper_decode(&mut codec_data).expect("Error decoding NGAP PDU");
eprintln!("Decoded NGAP PDU: {:#?}", ngap_pdu);
}
Loading