Hi Pino, thanks for the report and the patch!

On Sun Oct 27, 2024 at 10:51 AM CET, Pino Toscano wrote:
While this is a (arguably minor) bug in the Hurd part of glibc, I'm
submitting a local workaround here for the following reasons:
- mdocml is the only occurrence of this recvmsg() bug I've found so far
- it affects only the existance test, the actual mdocml code works fine
  (and the tests pass)
- submitting it to glibc and ensuring it is available in Debian will
  take a while

I'm ok with adding the patch to the Debian package for now, but I don't want to keep it here indefinitely. Could you please be sure a proper bug report (or fix) is submitted to glibc?

Author: Pino Toscano <p...@debian.org>
Description: Pass non-null msghdr to recvmsg()
 The Hurd implementation of recvmsg() in glibc does not handle a NULL value
 for the msghdr parameter, crashing (and thus failing the test).
 .
 Since this is a simple existance test, and the actual mdocml code uses properly
 filled msghdr's, then pass it a valid one also in the existance test.
 .
 This is a workaround for what glibc ought to handle better (i.e. not crash and
 return EINVAL); use it to keep building mdocml while a proper fix is done in
 glibc.
Forwarded: not-needed
Last-Update: 2014-10-27

I assume you meant 2024 here, right? (nice, descriptive patch description by the way, good job!)

--- a/test-recvmsg.c
+++ b/test-recvmsg.c
@@ -1,8 +1,11 @@
 #include <sys/socket.h>
 #include <stddef.h>
+#include <string.h>
int
 main(void)
 {
-       return recvmsg(-1, NULL, 0) != -1;
+       struct msghdr msg;
+       memset(&msg, 0, sizeof(msg));
+       return recvmsg(-1, &msg, 0) != -1;

Instead of creating a temporary variable explicitly, I'd use a compound literal. This would also result in a one-line change, and would not require including string.h.

-       return recvmsg(-1, NULL, 0) != -1;
+       return recvmsg(-1, &(struct msghdr){0}, 0) != -1;

 }

Thanks! Bye :)

Reply via email to