fix sprint_tm buffer size crash (reported by Japheth Cleaver)

pull/42/merge
David Schweikert 12 years ago
parent b0e09ce6fe
commit 70a29a11af

@ -1,4 +1,5 @@
UNRELEASED UNRELEASED
* fix sprint_tm buffer size crash (reported by Japheth Cleaver)
* fping.spec: fix setuid permissions and provides fping6 (Marcus Vinicius Ferreira) * fping.spec: fix setuid permissions and provides fping6 (Marcus Vinicius Ferreira)
* fix fping6 build on OS X 10.8 (unknown contributor) * fix fping6 build on OS X 10.8 (unknown contributor)

@ -2535,36 +2535,32 @@ char * sprint_tm( int t )
{ {
static char buf[10]; static char buf[10];
/* <= 0.99 ms */ if( t < 0 ) {
if( t < 100 ) /* negative (unexpected) */
{ sprintf( buf, "%.2g", (double) t / 100 );
}
else if( t < 100 ) {
/* <= 0.99 ms */
sprintf( buf, "0.%02d", t ); sprintf( buf, "0.%02d", t );
return( buf ); }
else if( t < 1000 ) {
}/* IF */ /* 1.00 - 9.99 ms */
/* 1.00 - 9.99 ms */
if( t < 1000 )
{
sprintf( buf, "%d.%02d", t / 100, t % 100 ); sprintf( buf, "%d.%02d", t / 100, t % 100 );
return( buf ); }
else if( t < 10000 ) {
}/* IF */ /* 10.0 - 99.9 ms */
/* 10.0 - 99.9 ms */
if( t < 10000 )
{
sprintf( buf, "%d.%d", t / 100, ( t % 100 ) / 10 ); sprintf( buf, "%d.%d", t / 100, ( t % 100 ) / 10 );
return( buf ); }
else if( t < 100000000 ) {
}/* IF */ /* 100 - 1'000'000 ms */
sprintf( buf, "%d", t / 100 );
/* >= 100 ms */ }
sprintf( buf, "%d", t / 100 ); else {
return( buf ); sprintf( buf, "%.2e", (double) (t / 100) );
}
} /* sprint_tm() */
return( buf );
}
/************************************************************ /************************************************************

Loading…
Cancel
Save