no more copy if the size is bigger than the ticket

This commit is contained in:
Detanup01 2024-04-29 20:51:54 +02:00 committed by otavepto
parent be42ac9b13
commit d6a4b7f0ba
2 changed files with 5 additions and 4 deletions

View File

@ -81,7 +81,7 @@ Auth_Data Auth_Manager::getTicketData( void *pTicket, int cbMaxTicket, uint32 *p
#define IP4_AS_DWORD_LITTLE_ENDIAN(a,b,c,d) (((uint32_t)d)<<24 | ((uint32_t)c)<<16 | ((uint32_t)b)<<8 | (uint32_t)a) #define IP4_AS_DWORD_LITTLE_ENDIAN(a,b,c,d) (((uint32_t)d)<<24 | ((uint32_t)c)<<16 | ((uint32_t)b)<<8 | (uint32_t)a)
Auth_Data ticket_data; Auth_Data ticket_data{};
CSteamID steam_id = settings->get_local_steam_id(); CSteamID steam_id = settings->get_local_steam_id();
if (settings->enable_new_app_ticket) if (settings->enable_new_app_ticket)
{ {
@ -127,7 +127,8 @@ Auth_Data Auth_Manager::getTicketData( void *pTicket, int cbMaxTicket, uint32 *p
} }
std::vector<uint8_t> ser = ticket_data.Serialize(); std::vector<uint8_t> ser = ticket_data.Serialize();
*pcbTicket = ser.size(); *pcbTicket = ser.size();
memcpy(pTicket, ser.data(), ser.size()); if (cbMaxTicket >= ser.size())
memcpy(pTicket, ser.data(), ser.size());
} }
else else
{ {
@ -189,7 +190,7 @@ uint32 Auth_Manager::getWebApiTicket( const char* pchIdentity )
GetTicketForWebApiResponse_t data{}; GetTicketForWebApiResponse_t data{};
uint32 cbTicket = 0; uint32 cbTicket = 0;
Auth_Data ticket_data = getTicketData(data.m_rgubTicket, STEAM_AUTH_TICKET_SIZE, &cbTicket); Auth_Data ticket_data = getTicketData(data.m_rgubTicket, STEAM_AUTH_TICKET_SIZE, &cbTicket);
if (*cbTicket > STEAM_AUTH_TICKET_SIZE) if (cbTicket > STEAM_AUTH_TICKET_SIZE)
return 0; return 0;
data.m_cubTicket = (int)cbTicket; data.m_cubTicket = (int)cbTicket;
uint32 ttt = ticket_data.number; uint32 ttt = ticket_data.number;

View File

@ -118,7 +118,7 @@ int InitiateGameConnection( void *pAuthBlob, int cbMaxAuthBlob, CSteamID steamID
if (!pAuthBlob) return 0; if (!pAuthBlob) return 0;
uint32 out_size = INITIATE_GAME_CONNECTION_TICKET_SIZE; uint32 out_size = INITIATE_GAME_CONNECTION_TICKET_SIZE;
auth_manager->getTicketData(pAuthBlob, INITIATE_GAME_CONNECTION_TICKET_SIZE, &out_size); auth_manager->getTicketData(pAuthBlob, INITIATE_GAME_CONNECTION_TICKET_SIZE, &out_size);
if (*out_size > INITIATE_GAME_CONNECTION_TICKET_SIZE) if (out_size > INITIATE_GAME_CONNECTION_TICKET_SIZE)
return 0; return 0;
return out_size; return out_size;
} }