Skip to content

Commit

Permalink
apple2: network open: stop at nul if present
Browse files Browse the repository at this point in the history
  • Loading branch information
markjfisher committed Oct 15, 2023
1 parent 31ff73c commit b960a5c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/device/iwm/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,15 @@ void iwmNetwork::send_status_dib_reply_packet()
*/
void iwmNetwork::open()
{
int idx = 0;
uint8_t _aux1 = data_buffer[idx++];
uint8_t _aux2 = data_buffer[idx++];
string d = string((char *)&data_buffer[idx], 256);
uint8_t _aux1 = data_buffer[0];
uint8_t _aux2 = data_buffer[1];

auto start = data_buffer + 2;
auto end = start + std::min<std::size_t>(256, sizeof(data_buffer) - 2);
auto null_pos = std::find(start, end, 0);

// ensure the string does not go past a null, but can be up to 256 bytes long if one not found
string d(start, null_pos);

Debug_printf("\naux1: %u aux2: %u path %s", _aux1, _aux2, d.c_str());

Expand Down

0 comments on commit b960a5c

Please sign in to comment.