public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] socket: Fix tst-cmsghdr-skeleton.c use of cmsg_len
@ 2023-05-01 13:05 Samuel Thibault
  0 siblings, 0 replies; only message in thread
From: Samuel Thibault @ 2023-05-01 13:05 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=7647d1901ea2b34fafd95ecddf52905a3d314368

commit 7647d1901ea2b34fafd95ecddf52905a3d314368
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date:   Mon May 1 14:48:06 2023 +0200

    socket: Fix tst-cmsghdr-skeleton.c use of cmsg_len
    
    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.

Diff:
---
 socket/tst-cmsghdr-skeleton.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/socket/tst-cmsghdr-skeleton.c b/socket/tst-cmsghdr-skeleton.c
index 296a0a8581..9516139f87 100644
--- a/socket/tst-cmsghdr-skeleton.c
+++ b/socket/tst-cmsghdr-skeleton.c
@@ -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);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-05-01 13:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-01 13:05 [glibc] socket: Fix tst-cmsghdr-skeleton.c use of cmsg_len Samuel Thibault

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).