Skip to content

Commit

Permalink
Merge pull request ReFirmLabs#776 from ReFirmLabs/dlink_tlv_no_checksum
Browse files Browse the repository at this point in the history
Support dlink_tlv firmware that do not include the header checksum
  • Loading branch information
devttys0 authored Nov 28, 2024
2 parents 2df9a00 + 1503e53 commit 2645c23
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/signatures/dlink_tlv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ pub fn dlink_tlv_parser(
if let Some(payload_data) = file_data.get(data_start..data_end) {
let payload_md5 = format!("{:x}", md5::compute(payload_data));

// Make sure the MD5 hashes match
if payload_md5 == tlv_header.data_checksum {
// If the MD5 checksum exists, make sure it matches
if tlv_header.data_checksum.is_empty() || payload_md5 == tlv_header.data_checksum {
result.size = tlv_header.header_size + tlv_header.data_size;
result.description = format!(
"{}, model name: {}, board ID: {}, header size: {} bytes, data size: {} bytes",
Expand Down
7 changes: 2 additions & 5 deletions src/structures/dlink_tlv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,8 @@ pub fn parse_dlink_tlv_header(tlv_data: &[u8]) -> Result<DlinkTLVHeader, Structu
header.data_checksum =
get_cstring(&header_data[MD5_HASH_OFFSET..MD5_HASH_OFFSET + MAX_STRING_LENGTH]);

// Make sure we got the expected strings OK
if !header.model_name.is_empty()
&& !header.board_id.is_empty()
&& !header.data_checksum.is_empty()
{
// Make sure we got the expected strings OK (checksum is not always included)
if !header.model_name.is_empty() && !header.board_id.is_empty() {
// Parse the type and length values that describe the data the follows the header
if let Ok(data_tlv) =
common::parse(&header_data[DATA_TLV_OFFSET..], &tlv_structure, "little")
Expand Down

0 comments on commit 2645c23

Please sign in to comment.