diff --git a/AUTHORS b/AUTHORS index e7a6efe..f61f99d 100644 --- a/AUTHORS +++ b/AUTHORS @@ -28,3 +28,6 @@ Andrew Gallatin Stephen Hemminger * Linux congestion control selection and theading improvements + +Nathan Jones + * patch for underflow when value specified in -n is not a multiple of -l diff --git a/ChangeLog b/ChangeLog index c7804f3..12d9c95 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-05-09 Nathan Jones + +* prevent underflow when the amount of data to be transmitted (-n) is not a +multiple of the buffer size (-l) Patch: +https://sourceforge.net/tracker/index.php?func=detail&aid=1943432&group_id=128336&atid=711373 + 2008-04-08 Jon Dugan * print report headers only once diff --git a/src/Client.cpp b/src/Client.cpp index e0a6950..c089ab0 100644 --- a/src/Client.cpp +++ b/src/Client.cpp @@ -170,7 +170,12 @@ void Client::RunTCP( void ) { } if ( !mMode_Time ) { - mSettings->mAmount -= currLen; + /* mAmount may be unsigned, so don't let it underflow! */ + if( mSettings->mAmount >= currLen ) { + mSettings->mAmount -= currLen; + } else { + mSettings->mAmount = 0; + } } } while ( ! (sInterupted || @@ -310,7 +315,12 @@ void Client::Run( void ) { delay_loop( delay ); } if ( !mMode_Time ) { - mSettings->mAmount -= currLen; + /* mAmount may be unsigned, so don't let it underflow! */ + if( mSettings->mAmount >= currLen ) { + mSettings->mAmount -= currLen; + } else { + mSettings->mAmount = 0; + } } } while ( ! (sInterupted ||