Thanks, how about this:
I've changed the packet format a bit. The first byte is still the message type, then followed by 6 characters for the account number, followed by 1 to 20 characters for the password. So the minimum packet size is 8 bytes, and maximum 27 bytes.
Code:
int f(unsigned char* data, unsigned int dataLength, SystemID sourceSystem)
{
char buff[21];
if(dataLength < 8 || dataLength > 27)
{
std::cout << "WARNING: corrupt LOGIN_REQUEST packet received from: \n"
<< "SystemID: " << sourceSystem << "\n"
<< "(IP:port): " << (net->getSystemAddress(sourceSystem)).ToString(true) << "\n"
<< (dataLength < 8 ? "packet too small" : "packet too large") << std::endl;
return 0;
}
strncpy_s(buff, 21, reinterpret_cast<char*>(data + 1), 6);
std::string acc(buff);
strncpy_s(buff, 21, reinterpret_cast<char*>(data + 1 + 6), dataLength - 7);
std::string pass(buff);
// testing only:
std::cout << acc << " " << acc.length() << "\n" << pass << " " << pass.length()
<< " " << dataLength << std::endl;
return 0;
}