fix memory overwrite in domain server

This commit is contained in:
Stephen Birarda 2013-02-18 09:30:50 -08:00
parent 615f04982c
commit 0cea1e80ff
2 changed files with 2 additions and 1 deletions

View file

@ -78,7 +78,7 @@ int addAgent(uint32_t ip, in_port_t port, char *private_ip, unsigned short priva
agents[i].active = true;
agents[i].public_sin_addr.s_addr = ip;
agents[i].public_port = port;
agents[i].private_addr = private_ip;
strcpy(agents[i].private_addr, private_ip);
agents[i].private_port = private_port;
agents[i].agentType = agentType;
gettimeofday(&agents[i].time, NULL);

View file

@ -62,6 +62,7 @@ int update_agents(char * data, int length) {
spot = packet.find_first_of (",", 0);
while (spot != std::string::npos) {
std::string thisAgent = packet.substr(start_spot, spot-start_spot);
std::cout << "RAW: " << thisAgent << "\n";
sscanf(thisAgent.c_str(), "%c %s %hd %s %hd", &agentType, public_address, &public_port, private_address, &private_port);
add_agent(public_address, public_port, private_address, private_port, agentType);
numAgents++;