[LTP] [PATCH] lib/tst_timer_test.c: fix unsigned int overflow on RHEL5.11GA
Xiao Yang
yangx.jy@cn.fujitsu.com
Mon Jul 17 08:53:57 CEST 2017
On RHEL5.11GA, pselect01 gets signal SIGSEGV due to unsigned int
overflow when all members of the samples array are less than usec
in do_timer_test(). all tests which apply timer measurement library
could trigger this issue on RHEL5.11GA regularly.
Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
---
lib/tst_timer_test.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/tst_timer_test.c b/lib/tst_timer_test.c
index f30ad73..178e232 100644
--- a/lib/tst_timer_test.c
+++ b/lib/tst_timer_test.c
@@ -295,9 +295,9 @@ void do_timer_test(long long usec, unsigned int nsamples)
i, samples[0], samples[i-1]);
}
- for (i = nsamples - 1; samples[i] < usec; i--);
+ for (i = nsamples - 1; i < nsamples && samples[i] < usec; i--);
- if (i < nsamples - 1) {
+ if (i != nsamples - 1) {
tst_res(TFAIL, "%s woken up early %u times range: [%lli,%lli]",
scall, nsamples - 1 - i,
samples[i+1], samples[nsamples-1]);
--
1.8.3.1
More information about the ltp
mailing list