Skip to content

Commit

Permalink
fix ar smart chunking header checks
Browse files Browse the repository at this point in the history
  • Loading branch information
moonshadow565 committed Oct 14, 2022
1 parent d9f6dbb commit f160330
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/rlib/ar_wad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ auto Ar::process_try_wad(IO const& io, offset_cb cb, Entry const& top_entry) con
#define read_header($V) \
do { \
WAD::Header::V##$V v_header = {}; \
rlib_assert(top_entry.size >= sizeof(header)); \
rlib_assert(top_entry.size >= sizeof(v_header)); \
io.read(top_entry.offset, {(char*)&v_header, sizeof(v_header)}); \
header.desc_size = v_header.desc_size; \
header.desc_count = v_header.desc_count; \
Expand All @@ -89,7 +89,7 @@ auto Ar::process_try_wad(IO const& io, offset_cb cb, Entry const& top_entry) con
break;
#undef read_header
default:
return "Unknown Ar::WAD version";
rlib_assert(!"Unknown Ar::WAD version");
}
rlib_assert(top_entry.size >= header.toc_start);
rlib_assert(top_entry.size - header.toc_start >= header.toc_size);
Expand Down
4 changes: 2 additions & 2 deletions lib/rlib/ar_wpk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ auto Ar::process_try_wpk(IO const& io, offset_cb cb, Entry const& top_entry) con
#define read_header($V) \
do { \
WPK::Header::V##$V v_header = {}; \
rlib_assert(top_entry.size >= sizeof(header)); \
rlib_assert(top_entry.size >= sizeof(v_header)); \
io.read(top_entry.offset, {(char*)&v_header, sizeof(v_header)}); \
header.desc_count = v_header.desc_count; \
header.toc_start = v_header.toc_start; \
Expand All @@ -57,7 +57,7 @@ auto Ar::process_try_wpk(IO const& io, offset_cb cb, Entry const& top_entry) con
break;
#undef read_header
default:
return "Unsuported Ar::WPK version!";
rlib_assert(!"Unsuported Ar::WPK version!");
}

rlib_assert(top_entry.size >= header.toc_start);
Expand Down

0 comments on commit f160330

Please sign in to comment.