"man 3 cmsg" says "Ancillary data should only be accessed using the
CMSG macros and never directly." Indeed, when we handles cmsghdr mamber
directly, this test falls into the infinite loop on a x86_64 environment.

Signed-off-by: Mitsuru Chinen <[EMAIL PROTECTED]>
---
 testcases/network/lib6/asapi_06.c |   12 +++---------
 1 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/testcases/network/lib6/asapi_06.c 
b/testcases/network/lib6/asapi_06.c
index 48fbdf0..ad0cdae 100644
--- a/testcases/network/lib6/asapi_06.c
+++ b/testcases/network/lib6/asapi_06.c
@@ -349,7 +349,7 @@ so_test(struct soent *psoe)
 
        /* receiver processing */
        { fd_set rfds, rfds_saved;
-         int nfds, cc, len;
+         int nfds, cc;
          int gotone;
          struct timeval tv;
          struct msghdr msg;
@@ -400,12 +400,10 @@ so_test(struct soent *psoe)
                        break;
                }
                gotone = 0;
-               pcmsg = (struct cmsghdr *)msg.msg_control;
-               for (len=0; len < msg.msg_controllen; len += pcmsg->cmsg_len) {
+               for (pcmsg = CMSG_FIRSTHDR(&msg); pcmsg != NULL;
+                               pcmsg = CMSG_NXTHDR(&msg, pcmsg)) {
                        if (!psoe->so_dorecv)
                                break;
-                       pcmsg = (struct cmsghdr *)(((unsigned char *)
-                               msg.msg_control) + len);
                        gotone = pcmsg->cmsg_level == SOL_IPV6 &&
                            pcmsg->cmsg_type == psoe->so_cmtype;
                        if (gotone)
@@ -418,10 +416,6 @@ so_test(struct soent *psoe)
                                return;
                        }
                }
-               if (gotone && pcmsg->cmsg_len > 0) {
-                       unsigned int *cmdat = (unsigned int *)
-                               ((unsigned char *)pcmsg+sizeof(struct cmsghdr));
-               }
 /* check contents here */
                if (psoe->so_dorecv)
                        tst_resm(gotone ? TPASS : TFAIL, "%s receive",
-- 
1.5.4.5


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to