Skip to content

Commit

Permalink
fix encoding of the plus version (version components were sent as cha…
Browse files Browse the repository at this point in the history
…racters), make sure build number doesn't overflow
  • Loading branch information
uuuzbf committed Apr 29, 2024
1 parent fdd9e55 commit ace0308
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/bfhook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ void patch_add_plus_version_to_accept_ack()
uint8_t major, minor, patch, build;
get_build_version_components(major, minor, patch, build);
data[1] = '+';
data[2] = 0x40 | (build & 0xF); // set high 4 bits to 4 so the crc will be correct
data[2] = 0x40 | ((build > 15 ? 15 : build) & 0xF); // set high 4 bits to 4 so the crc will be correct
data[3] = major;
data[4] = minor;
data[5] = patch;
Expand Down
9 changes: 5 additions & 4 deletions src/updater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,16 @@ static const wchar_t* get_user_agent()

void get_build_version_components(uint8_t& major, uint8_t& minor, uint8_t& patch, uint8_t& build)
{
uint16_t tmp;
major = minor = patch = build = 0;
auto ver = std::stringstream(M_TO_STRING(GIT_VERSION));
ver >> major;
ver >> tmp; major = (uint8_t)tmp;
ver.get(); // skip delimiter
ver >> minor;
ver >> tmp; minor = (uint8_t)tmp;
ver.get(); // skip delimiter
ver >> patch;
ver >> tmp; patch = (uint8_t)tmp;
ver.get(); // skip delimiter
ver >> build;
ver >> tmp; build = (uint8_t)tmp;
}

int compare_version(std::wstring older, std::wstring newer)
Expand Down

0 comments on commit ace0308

Please sign in to comment.