Your message dated Sat, 01 Aug 2026 15:19:01 +0000
with message-id <[email protected]>
and subject line Bug#1142663: fixed in libsocket-msghdr-perl 0.06-2
has caused the Debian Bug report #1142663,
regarding libsocket-msghdr-perl: recvmsg fails to set flags (.msg_flags)
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
1142663: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1142663
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: libsocket-msghdr-perl
Version: 0.05-2+b4
Severity: normal
Tags: patch upstream

Dear Maintainer,

recvmsg in Socket::MsgHdr fails to set the `flags' value to
what the recvmsg(2) syscall writes to `struct msghdr'.msg_flags.

This makes it impossible to detect truncation errors such as
MSG_TRUNC and MSG_CTRUNC when the `buflen' and `controllen'
fields are too small.  Attached is a patch which fixes the
issue in upstream.

Unfortunately, I cannot contribute directly to upstream due to
Terms of Service and JS requirement of Github causing
accessibility problems.
>From af9d3624155ab51cd752f27981ef3b7287d24153 Mon Sep 17 00:00:00 2001
From: Eric Wong <[email protected]>
Date: Thu, 23 Jul 2026 20:54:15 +0000
Subject: [PATCH] recvmsg: set `flags' field according to .msg_flags

The .msg_flags field of `struct msghdr' gets populated by the
recvmsg(2) syscall.  Most notably, .msg_flags allows the
receiver to detect truncation via MSG_TRUNC and MSG_CTRUNC flags
when the supplied `buflen' and/or `controllen' fields are too
small.

Note that MSG_TRUNC set in .msg_flags by recvfrom is different
from the `flags' argument.  MSG_TRUNC in the `flags' argument
changes the return value of recvfrom(2) to the intended length
of the data, whereas .msg_flags merely tells the caller the
buffer is too small and does not tell the intended length.

MSG_TRUNC in the `flags' argument probably makes the most sense
with MSG_PEEK, as shown in the below example to dynamically
size `buflen' to the necessary value to avoid MSG_TRUNC in
.msg_flags in a subsequent recvmsg call:

  use Socket;
  use Socket::MsgHdr;
  my ($rd, $wr);
  socketpair($rd, $wr, AF_UNIX, SOCK_DGRAM, 0) or die "socketpair: $!";
  my $hdr = Socket::MsgHdr->new(buf => 'ab');
  sendmsg($wr, $hdr, 0) or die "sendmsg: $!";
  my $m = Socket::MsgHdr->new(buflen => 1);
  my $r = recvmsg($rd, $m, MSG_TRUNC|MSG_PEEK) or die "recvmsg: $!";
  print "MSG_TRUNC=", MSG_TRUNC, "\n";
  print "before: r=$r flags=", $m->flags,
        " (expecting (flags & MSG_TRUNC=${\MSG_TRUNC}))\n";
  $m = Socket::MsgHdr->new(buflen => $r);
  recvmsg($rd, $m, 0) or die "recvmsg: $!";
  print " after: r=$r flags=", $m->flags, " (expecting flags==0)\n";
---
 MsgHdr.xs  |  4 ++++
 t/30recv.t | 40 +++++++++++++++++++++++++++++++++++++++-
 2 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/MsgHdr.xs b/MsgHdr.xs
index 0e4b932..9b7123a 100644
--- a/MsgHdr.xs
+++ b/MsgHdr.xs
@@ -158,6 +158,10 @@ smh_recvmsg(s, msg_hdr, flags = 0)
             SvCUR_set(*svp, RETVAL);
         if ((svp = hv_fetch(hsh, "control", 7, FALSE)))
             SvCUR_set(*svp, mh.m.msg_controllen);
+        if ((svp = hv_fetch(hsh, "flags", 5, FALSE))) {
+            SvUPGRADE(*svp, SVt_IV);
+            SvIV_set(*svp, mh.m.msg_flags);
+        }
     }
     OUTPUT:
     RETVAL
diff --git a/t/30recv.t b/t/30recv.t
index 7bb2b8e..c12daa4 100644
--- a/t/30recv.t
+++ b/t/30recv.t
@@ -6,7 +6,7 @@
 # change 'tests => 1' to 'tests => last_test_to_print';
 
 use Test::More;
-BEGIN { plan tests => 9 };
+BEGIN { plan tests => 11 };
 use bytes;
 use strict;
 use Socket;
@@ -124,4 +124,42 @@ SKIP: {
 
   cmp_ok($dev1, '==', $dev2, "scm_rights fds on same device");
   cmp_ok($ino1, '==', $ino2, "scm_rights fds are same inode");
+
+  eval { &MSG_CTRUNC; }; # autoloaded, may not be defined yet
+  skip "msg_ctrunc not defined", 1 if $@;
+
+  socketpair(Rd, Wr, AF_UNIX, SOCK_DGRAM, 0)
+    or die "socketpair: $!\n";
+
+  $hdr = new Socket::MsgHdr(buf => "hello!");
+  $hdr->cmsghdr(SOL_SOCKET, SCM_RIGHTS, pack('i', fileno STDIN));
+  sendmsg(\*Wr, $hdr, 0)
+    or die "sendmsg: $!\n";
+
+  $m = new Socket::MsgHdr(buflen => 256, controllen => 1);
+  recvmsg(\*Rd, $m, 0)
+    or die "recvmsg: $!\n";
+
+  ok($m->flags & MSG_CTRUNC, 'MSG_CTRUNC set when controllen is too short');
+
+  close Rd; close Wr;
+};
+
+# 11
+SKIP: {
+  local (*Rd, *Wr);
+  socketpair(Rd, Wr, AF_UNIX, SOCK_DGRAM, 0)
+    or die "socketpair: $!\n";
+
+  my $hdr = new Socket::MsgHdr(buf => 'ab');
+  sendmsg(\*Wr, $hdr, 0)
+    or die "sendmsg: $!\n";
+
+  my $m = new Socket::MsgHdr(buflen => 1);
+  recvmsg(\*Rd, $m, 0)
+    or die "recvmsg: $!\n";
+
+  ok($m->flags & MSG_TRUNC, 'MSG_TRUNC set when buflen is too short');
+
+  close Rd; close Wr;
 };

--- End Message ---
--- Begin Message ---
Source: libsocket-msghdr-perl
Source-Version: 0.06-2
Done: gregor herrmann <[email protected]>

We believe that the bug you reported is fixed in the latest version of
libsocket-msghdr-perl, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to [email protected],
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
gregor herrmann <[email protected]> (supplier of updated libsocket-msghdr-perl 
package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing [email protected])


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Format: 1.8
Date: Sat, 01 Aug 2026 16:54:00 +0200
Source: libsocket-msghdr-perl
Architecture: source
Version: 0.06-2
Distribution: unstable
Urgency: medium
Maintainer: Debian Perl Group <[email protected]>
Changed-By: gregor herrmann <[email protected]>
Closes: 1142663
Changes:
 libsocket-msghdr-perl (0.06-2) unstable; urgency=medium
 .
   * Team upload.
   * Re-upload after git-debpush error.
 .
 libsocket-msghdr-perl (0.06-1) unstable; urgency=medium
 .
   * Team upload.
   * Import upstream version 0.06.
     Fixes "recvmsg fails to set flags (.msg_flags)"
     (Closes: #1142663)
   * Declare compliance with Debian Policy 4.7.4.
   * Remove «Rules-Requires-Root: no», which is the current default.
   * Remove «Priority: optional», which is the current default.
Checksums-Sha1:
 0f79a04ec3ae9ad0353de2d4fcda3c0e702dde0d 2394 libsocket-msghdr-perl_0.06-2.dsc
 95c1b03302304b420d18b40e429416876b14a954 3132 
libsocket-msghdr-perl_0.06-2.debian.tar.xz
 8535eef57e14135c338e6f4126b41df3a4d0e33f 55652 
libsocket-msghdr-perl_0.06.orig.tar.gz
Checksums-Sha256:
 8ed37d97583fb56326d95397db65e1acd0df4d12a9d213d7b593365c752220f0 2394 
libsocket-msghdr-perl_0.06-2.dsc
 019902bc2e9391f9a01c5369640e09d748e2c1b568cca2d9d0a334df3220fe82 3132 
libsocket-msghdr-perl_0.06-2.debian.tar.xz
 7912a9716799793cab9eea1fc239a52afb932df2a4cf30c4025432edf08a0600 55652 
libsocket-msghdr-perl_0.06.orig.tar.gz
Files:
 839689e9fbea103b18495907290b51ff 2394 perl optional 
libsocket-msghdr-perl_0.06-2.dsc
 c7f9ca89e558edf40d415008df4221b8 3132 perl optional 
libsocket-msghdr-perl_0.06-2.debian.tar.xz
 0c4e3b2aeae57730393f7ef8197cde21 55652 perl optional 
libsocket-msghdr-perl_0.06.orig.tar.gz

-----BEGIN PGP SIGNATURE-----

iQKTBAEBCgB9FiEE0eExbpOnYKgQTYX6uzpoAYZJqgYFAmpuCPBfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldEQx
RTEzMTZFOTNBNzYwQTgxMDREODVGQUJCM0E2ODAxODY0OUFBMDYACgkQuzpoAYZJ
qgYc1Q/+OYt0Otu1VzfmtD6IWqJydegTeQvCX3DDWpnnHfr+vQVWWfz/mPgXXi1J
36iAe2eL38ZzGQW4ei7VCzWLGvxGhJoJsWQIi5LObSn4uDxpb660VLTNfJTLETvI
vhCA41QjiyRfKxF14t1kyQE0qmA2ESCNnGCSL8JP1khGblWyVJ2IAwVkZHcr2TZ7
9wBcjTzcKeouE2YxgxqjOjf1WoZnmGXjnz+XaSvy7hSmcn0MIiLoxSg1gJKqViXA
j1oAkS2xjRK18xIsLxjRCmgJ5nx1El91PgWQvDQHPnptE3p84NJmnehZ2V3X6Bt8
aUVdqdiO5wTw2ykvP+wJncTyJNaGV4biaJ8G7fUd/MvVXJG6inqZm1xVf256Jqh+
xFznLusLTvo+YRON2jMyk58+VDgX1VjXNZeysRFhkme8Sx+GB6tjpRCjQTZzbFgk
SggkUPnxsDkGSr/C30hA8fWwQz32TxqNwmALQYll7zFD8fz3939z16dhyMTO6ggN
xCtVk9n2a0RbE+uA31oss1YLlrAybLfvo1mEeapehFfBXl0albz8vbcMMT+Yq5/q
J7OHLVUdH4J/oAWUjP4Mfpg0p9a6B04lFmJcJZcg2RzBWAGj00/Ygn2DxRHvt0K6
/WroSsaM+ZG7kZt8s82JBk99m3LEb13/+01MVOyoyF3SyB/g3eU=
=tREV
-----END PGP SIGNATURE-----

Attachment: pgpPjky4ykIoa.pgp
Description: PGP signature


--- End Message ---

Reply via email to