1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
--- iperf-2.0.4-4/AUTHORS 2009-07-06 12:02:24.159696747 +0200
+++ iperf-2.0.4/AUTHORS 2009-07-06 12:14:32.236079541 +0200
@@ -28,3 +28,7 @@
Stephen Hemminger <shemminger@linux-foundation.org>
* Linux congestion control selection and theading improvements
+
+Nathan Jones <nmjones@users.sourceforge.net>
+ * patch for underflow when value specified in -n is not a multiple of -l
+
--- iperf-2.0.4-4/ChangeLog 2009-07-06 12:02:24.166276642 +0200
+++ iperf-2.0.4/ChangeLog 2009-07-06 12:15:28.883699655 +0200
@@ -1,3 +1,18 @@
+2008-05-09 Jon Dugan <jdugan@x1024.net>
+
+* change currLen to unsigned to squelch warning generated by Nathan's patch
+
+2008-05-09 Nathan Jones <nmjones@users.sourceforge.net>
+
+* 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 <jdugan@x1024.net>
+
+* print report headers only once
+* use appropriate report header for UDP tests
+
2008-04-07 Jon Dugan <jdugan@x1024.net>
* Add man page to autoconf goo
diff -urN 204orig/src/Client.cpp trunk/src/Client.cpp
--- 204orig/src/Client.cpp 2008-04-08 04:37:54.000000000 +0200
+++ trunk/src/Client.cpp 2008-05-10 05:18:35.000000000 +0200
@@ -116,7 +116,7 @@
const int kBytes_to_Bits = 8;
void Client::RunTCP( void ) {
- long currLen = 0;
+ unsigned long currLen = 0;
struct itimerval it;
max_size_t totLen = 0;
@@ -170,7 +170,12 @@
}
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 ||
@@ -198,7 +203,7 @@
void Client::Run( void ) {
struct UDP_datagram* mBuf_UDP = (struct UDP_datagram*) mBuf;
- long currLen = 0;
+ unsigned long currLen = 0;
int delay_target = 0;
int delay = 0;
@@ -310,7 +315,12 @@
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 ||
diff -urN 204orig/src/ReportDefault.c trunk/src/ReportDefault.c
--- 204orig/src/ReportDefault.c 2008-04-08 04:37:54.000000000 +0200
+++ trunk/src/ReportDefault.c 2008-04-09 02:08:11.000000000 +0200
@@ -67,6 +67,7 @@
* Prints transfer reports in default style
*/
void reporter_printstats( Transfer_Info *stats ) {
+ static char header_printed = 0;
byte_snprintf( buffer, sizeof(buffer)/2, (double) stats->TotalLen,
toupper( stats->mFormat));
@@ -76,13 +77,19 @@
if ( stats->mUDP != (char)kMode_Server ) {
// TCP Reporting
- printf( report_bw_header);
+ if( !header_printed ) {
+ printf( report_bw_header);
+ header_printed = 1;
+ }
printf( report_bw_format, stats->transferID,
stats->startTime, stats->endTime,
buffer, &buffer[sizeof(buffer)/2] );
} else {
// UDP Reporting
- printf( report_bw_jitter_loss_header);
+ if( !header_printed ) {
+ printf( report_bw_jitter_loss_header);
+ header_printed = 1;
+ }
printf( report_bw_jitter_loss_format, stats->transferID,
stats->startTime, stats->endTime,
buffer, &buffer[sizeof(buffer)/2],
|