summaryrefslogtreecommitdiff
path: root/vendor/golang.org/x/sys/unix/sockcmsg_unix.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2022-11-28 11:19:39 +0100
committerLibravatar GitHub <noreply@github.com>2022-11-28 11:19:39 +0100
commitdaf44ac2b709922512cfee3cde686b84b4868775 (patch)
tree2967df466f8d4515d32c05cf520ba3e7a19d4fae /vendor/golang.org/x/sys/unix/sockcmsg_unix.go
parent[chore]: Bump codeberg.org/gruf/go-store/v2 from 2.0.9 to 2.0.10 (#1160) (diff)
downloadgotosocial-daf44ac2b709922512cfee3cde686b84b4868775.tar.xz
[chore] Bump database dependencies (#1164)
github.com/uptrace/bun v1.1.8 -> v1.1.9 github.com/uptrace/bun/pgdialect v1.1.8 -> v1.1.9 github.com/uptrace/bun/sqlitedialect v1.1.8 -> v1.1.9 modernc.org/sqlite v1.18.2 -> v1.19.5
Diffstat (limited to 'vendor/golang.org/x/sys/unix/sockcmsg_unix.go')
-rw-r--r--vendor/golang.org/x/sys/unix/sockcmsg_unix.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/vendor/golang.org/x/sys/unix/sockcmsg_unix.go b/vendor/golang.org/x/sys/unix/sockcmsg_unix.go
index 453a942c5..3865943f6 100644
--- a/vendor/golang.org/x/sys/unix/sockcmsg_unix.go
+++ b/vendor/golang.org/x/sys/unix/sockcmsg_unix.go
@@ -52,6 +52,20 @@ func ParseSocketControlMessage(b []byte) ([]SocketControlMessage, error) {
return msgs, nil
}
+// ParseOneSocketControlMessage parses a single socket control message from b, returning the message header,
+// message data (a slice of b), and the remainder of b after that single message.
+// When there are no remaining messages, len(remainder) == 0.
+func ParseOneSocketControlMessage(b []byte) (hdr Cmsghdr, data []byte, remainder []byte, err error) {
+ h, dbuf, err := socketControlMessageHeaderAndData(b)
+ if err != nil {
+ return Cmsghdr{}, nil, nil, err
+ }
+ if i := cmsgAlignOf(int(h.Len)); i < len(b) {
+ remainder = b[i:]
+ }
+ return *h, dbuf, remainder, nil
+}
+
func socketControlMessageHeaderAndData(b []byte) (*Cmsghdr, []byte, error) {
h := (*Cmsghdr)(unsafe.Pointer(&b[0]))
if h.Len < SizeofCmsghdr || uint64(h.Len) > uint64(len(b)) {