Hi, all!
A tweak to improve recvfrom01.c and recvmsg01.c --
there's a loop in the child server process which walks all available fds and
attempts to read those where the relevant fd_set bit is set.
Sadly, when there's more file descriptors available than bits in the fd_set,
this loop will happily walk off the end of the fd_set, clearing bits along the
way.
This leads to intermittent segfaults and thus false positives in these two
tests.
Immediate fix is to force the loop not to look at bits off the end of the
fd_set.
I've no idea whether it makes sense to rewrite the server code of these two
tests, as only under heavy socket / fd use would the accept() calls in the
tests return a file descriptor outside the fd_set.
Thanks!
Joseph
Joseph Beckenbach, senior QA engineer : Automation
=====
diff --git a/testcases/kernel/syscalls/recvfrom/recvfrom01.c
b/testcases/kernel/syscalls/recvfrom/recvfrom01.c
index b5ab4a0..5e68d98 100644
--- a/testcases/kernel/syscalls/recvfrom/recvfrom01.c
+++ b/testcases/kernel/syscalls/recvfrom/recvfrom01.c
@@ -319,7 +319,7 @@ void do_child()
/* send something back */
(void)write(newfd, "hoser\n", 6);
}
- for (fd = 0; fd < nfds; ++fd)
+ for (fd = 0; fd < nfds && fd < FD_SETSIZE; ++fd)
if (fd != sfd && FD_ISSET(fd, &rfds)) {
cc = read(fd, buf, sizeof(buf));
if (cc == 0 || (cc < 0 && errno != EINTR)) {
diff --git a/testcases/kernel/syscalls/recvmsg/recvmsg01.c
b/testcases/kernel/syscalls/recvmsg/recvmsg01.c
index dd6b3d5..5492c1d 100644
--- a/testcases/kernel/syscalls/recvmsg/recvmsg01.c
+++ b/testcases/kernel/syscalls/recvmsg/recvmsg01.c
@@ -481,7 +481,7 @@ void do_child()
if (newfd >= 0)
FD_SET(newfd, &afds);
}
- for (fd = 0; fd < nfds; ++fd)
+ for (fd = 0; fd < nfds && fd < FD_SETSIZE; ++fd)
if (fd != sfd && fd != ufd && FD_ISSET(fd, &rfds)) {
char rbuf[1024];
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list