Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion src/native/corehost/bundle/file_entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ file_entry_t file_entry_t::read(reader_t &reader, uint32_t bundle_major_version,
reader.read(&fixed_data.compressedSize, sizeof(int64_t));
}

fixed_data.type = *(file_type_t*)reader.read_direct(sizeof(file_type_t));
fixed_data.type = (file_type_t)reader.read_byte();

file_entry_t entry(&fixed_data, force_extraction);

Expand Down
12 changes: 6 additions & 6 deletions src/native/corehost/bundle/header.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@ bool header_fixed_t::is_valid() const

header_t header_t::read(reader_t& reader)
{
const header_fixed_t* fixed_header = reinterpret_cast<const header_fixed_t*>(reader.read_direct(sizeof(header_fixed_t)));
header_fixed_t fixed_header;
reader.read(&fixed_header, sizeof(header_fixed_t));

if (!fixed_header->is_valid())
if (!fixed_header.is_valid())
{
trace::error(_X("Failure processing application bundle."));
trace::error(_X("Bundle header version compatibility check failed. Header version: %d.%d"), fixed_header->major_version, fixed_header->minor_version);
trace::error(_X("Bundle header version compatibility check failed. Header version: %d.%d"), fixed_header.major_version, fixed_header.minor_version);

throw StatusCode::BundleExtractionFailure;
}

header_t header(fixed_header->major_version, fixed_header->minor_version, fixed_header->num_embedded_files);
header_t header(fixed_header.major_version, fixed_header.minor_version, fixed_header.num_embedded_files);

// bundle_id is a component of the extraction path
reader.read_path_string(header.m_bundle_id);

const header_fixed_v2_t *v2_header = reinterpret_cast<const header_fixed_v2_t*>(reader.read_direct(sizeof(header_fixed_v2_t)));
header.m_v2_header = *v2_header;
reader.read(&header.m_v2_header, sizeof(header_fixed_v2_t));

return header;
}
10 changes: 3 additions & 7 deletions src/native/corehost/bundle/reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,10 @@ namespace bundle
m_ptr += len;
}

// Return a pointer to the requested bytes within the memory-mapped file.
// Skip over len bytes.
const char* read_direct(int64_t len)
uint8_t read_byte()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: since this is only used from one place, is it worth adding? Why not just use the read even for the single byte file type?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noticed the same thing - there is read(), which is the same as read_byte()

{
bounds_check(len);
const char *ptr = m_ptr;
m_ptr += len;
return ptr;
bounds_check(1);
return (uint8_t)*m_ptr++;
}

size_t read_path_length();
Expand Down