Improve code security posture by replacing sprintf with a safer function.

This commit is contained in:
Adam Ierymenko 2013-08-30 17:05:43 -04:00
parent 1a7e303f97
commit f3ad05347e
16 changed files with 75 additions and 69 deletions

View file

@ -376,32 +376,6 @@ static int testOther()
return 0;
}
static int testRateLimiter()
{
RateLimiter limiter;
RateLimiter::Limit limit;
std::cout << "[ratelimiter] preload: 10000.0, rate: 1000.0/sec, max: 15000.0, min: -7500.0" << std::endl;
limit.bytesPerSecond = 1000.0;
limit.maxBalance = 15000.0;
limit.minBalance = -7500.0;
limiter.init(10000.0);
for(int i=0;i<25;++i) {
Thread::sleep(100);
std::cout << "[ratelimiter] delayed 0.1s, gate(1000.0): " << (limiter.gate(limit,1000.0) ? "OK" : "BLOCK");
std::cout << " (new balance afterwords: " << limiter.balance() << ")" << std::endl;
}
std::cout << "[ratelimiter] delaying 15s..." << std::endl;
Thread::sleep(15000);
for(int i=0;i<20;++i) {
Thread::sleep(1000);
std::cout << "[ratelimiter] delayed 1s, gate(2000.0): " << (limiter.gate(limit,2000.0) ? "OK" : "BLOCK");
std::cout << " (new balance afterwords: " << limiter.balance() << ")" << std::endl;
}
return 0;
}
#ifdef __WINDOWS__
int _tmain(int argc, _TCHAR* argv[])
#else
@ -417,7 +391,6 @@ int main(int argc,char **argv)
r |= testPacket();
r |= testOther();
r |= testIdentity();
r |= testRateLimiter();
if (r)
std::cout << std::endl << "SOMETHING FAILED!" << std::endl;