]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
socket: Fix tst-cmsghdr-skeleton.c use of cmsg_len
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Mon, 1 May 2023 12:48:06 +0000 (14:48 +0200)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Mon, 1 May 2023 13:05:09 +0000 (15:05 +0200)
cmsg_len is supposed to be socklen_t according to standards, but it was made
size_t on Linux, see BZ 16919. For ports that have it socklen_t, SIZE_MAX is
too large. We can however explicitly cast it to the type of cmsg_len so it
will fit according to that type.

socket/tst-cmsghdr-skeleton.c

index 296a0a85812f9ff690d431f10f377c116ca51636..9516139f875d55f58ac5a0d29418742a6e7ad9a2 100644 (file)
@@ -49,7 +49,7 @@ RUN_TEST_FUNCNAME (CMSG_NXTHDR_IMPL) (void)
   /* The first header length is so big, using it would cause an overflow.  */
   cmsg = CMSG_FIRSTHDR (&m);
   TEST_VERIFY_EXIT ((char *) cmsg == cmsgbuf);
-  cmsg->cmsg_len = SIZE_MAX;
+  cmsg->cmsg_len = (__typeof (cmsg->cmsg_len)) SIZE_MAX;
   cmsg = CMSG_NXTHDR_IMPL (&m, cmsg);
   TEST_VERIFY_EXIT (cmsg == NULL);