Skip to content

Commit

Permalink
Fix SVCDSCDIR replies on 64-bit big endian architectures
Browse files Browse the repository at this point in the history
While on LE this works, on BE it copies the other four bytes into
the uint32_t, resulting in a zero. This in turn results in a
protocol error on those architectures.
  • Loading branch information
q66 authored and davmac314 committed Nov 24, 2024
1 parent 93e69a5 commit daad6a3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/control.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1315,7 +1315,7 @@ bool control_conn_t::process_query_dsc_dir()
// 4 bytes (uint32_t) = directory length (no nul terminator)
// N bytes = directory (no nul)
std::vector<char> reppkt;
size_t sdir_len = strlen(service->get_service_dsc_dir());
auto sdir_len = static_cast<uint32_t>(strlen(service->get_service_dsc_dir()));
reppkt.resize(1 + sizeof(uint32_t) + sdir_len); // packet type, dir length, dir
reppkt[0] = (char)cp_rply::SVCDSCDIR;
std::memcpy(&reppkt[1], &sdir_len, sizeof(sdir_len));
Expand Down

0 comments on commit daad6a3

Please sign in to comment.