]> Cypherpunks repositories - gostls13.git/commitdiff
syscall: remove X__cmsg_data from Cmsghdr
authorIan Gudger <igudger@google.com>
Sat, 29 Oct 2016 03:09:02 +0000 (20:09 -0700)
committerRuss Cox <rsc@golang.org>
Sun, 30 Oct 2016 19:04:09 +0000 (19:04 +0000)
This field is a zero length array and has little use. Since Go 1.5, trailing
zero-length arrays take up space. Both syscall.UnixRights() and
syscall.ParseSocketControlMessage() depend on being able to do an unsafe cast
of socket control message data to Cmsghdr this is only safe if the socket
control message data is greater than or equal to the size of Cmsghdr. Since
control message data that is equal in size to Cmsghdr without X__cmsg_data is
a valid socket control message, we must remove X__cmsg_data or not perform the
unsafe cast.

Removing X__cmsg_data will prevent Go code that uses X__cmsg_data from
compiling, but removing the unsafe cast will cause Go code that uses
X__cmsg_data to fail or exhibit undefined behavior at runtime. It was
therefore decided that removing X__cmsg_data was the better option.

Fixes #17649

Change-Id: I39f323f978eca09d62da5785c5c5c9c7cbdf8c31
Reviewed-on: https://go-review.googlesource.com/32319
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

api/except.txt
src/syscall/ztypes_linux_386.go
src/syscall/ztypes_linux_amd64.go
src/syscall/ztypes_linux_arm.go
src/syscall/ztypes_linux_arm64.go
src/syscall/ztypes_linux_mips64.go
src/syscall/ztypes_linux_mips64le.go
src/syscall/ztypes_linux_ppc64.go
src/syscall/ztypes_linux_ppc64le.go

index 93302ec819cb321e0369ceb46aee179d771ac265..cd5d8e0df5dfdd72fdee6951e231cfd472e49a22 100644 (file)
@@ -19,6 +19,12 @@ pkg syscall (darwin-386), const ImplementsGetwd = false
 pkg syscall (darwin-386-cgo), const ImplementsGetwd = false
 pkg syscall (darwin-amd64), const ImplementsGetwd = false
 pkg syscall (darwin-amd64-cgo), const ImplementsGetwd = false
+pkg syscall (linux-386), type Cmsghdr struct, X__cmsg_data [0]uint8
+pkg syscall (linux-386-cgo), type Cmsghdr struct, X__cmsg_data [0]uint8
+pkg syscall (linux-amd64), type Cmsghdr struct, X__cmsg_data [0]uint8
+pkg syscall (linux-amd64-cgo), type Cmsghdr struct, X__cmsg_data [0]uint8
+pkg syscall (linux-arm), type Cmsghdr struct, X__cmsg_data [0]uint8
+pkg syscall (linux-arm-cgo), type Cmsghdr struct, X__cmsg_data [0]uint8
 pkg syscall (openbsd-386), const BIOCGRTIMEOUT = 1074283118
 pkg syscall (openbsd-386), const BIOCSRTIMEOUT = 2148024941
 pkg syscall (openbsd-386), const RTF_FMASK = 63496
index dd198cb394fb900647acc04435e5672783e15f18..a73c91770f909e6ec234a697a761efda493d9c56 100644 (file)
@@ -238,10 +238,9 @@ type Msghdr struct {
 }
 
 type Cmsghdr struct {
-       Len          uint32
-       Level        int32
-       Type         int32
-       X__cmsg_data [0]uint8
+       Len   uint32
+       Level int32
+       Type  int32
 }
 
 type Inet4Pktinfo struct {
index a39489e4e52d2518d91dea5ee4894caeea33a0a8..4cbd5d899de9c7d4e938b8422cc70e65c44d687a 100644 (file)
@@ -242,10 +242,9 @@ type Msghdr struct {
 }
 
 type Cmsghdr struct {
-       Len          uint64
-       Level        int32
-       Type         int32
-       X__cmsg_data [0]uint8
+       Len   uint64
+       Level int32
+       Type  int32
 }
 
 type Inet4Pktinfo struct {
index f446e41be0f2817f88fd831079447ce791576199..16aa014adac56c6e39198c8dae16a9bfed2fab4d 100644 (file)
@@ -242,10 +242,9 @@ type Msghdr struct {
 }
 
 type Cmsghdr struct {
-       Len          uint32
-       Level        int32
-       Type         int32
-       X__cmsg_data [0]uint8
+       Len   uint32
+       Level int32
+       Type  int32
 }
 
 type Inet4Pktinfo struct {
index dcb1178dc426b16803ac291dfd10af61a916fb67..e5d669cdba712555157a054a563cef686e891cfc 100644 (file)
@@ -243,10 +243,9 @@ type Msghdr struct {
 }
 
 type Cmsghdr struct {
-       Len          uint64
-       Level        int32
-       Type         int32
-       X__cmsg_data [0]uint8
+       Len   uint64
+       Level int32
+       Type  int32
 }
 
 type Inet4Pktinfo struct {
index 909308617ecba9fad5e3362fa2e6049d0f7b945a..925afb9d1c26aaa62574f8c98ffc4494e17188c8 100644 (file)
@@ -244,10 +244,9 @@ type Msghdr struct {
 }
 
 type Cmsghdr struct {
-       Len          uint64
-       Level        int32
-       Type         int32
-       X__cmsg_data [0]uint8
+       Len   uint64
+       Level int32
+       Type  int32
 }
 
 type Inet4Pktinfo struct {
index 909308617ecba9fad5e3362fa2e6049d0f7b945a..925afb9d1c26aaa62574f8c98ffc4494e17188c8 100644 (file)
@@ -244,10 +244,9 @@ type Msghdr struct {
 }
 
 type Cmsghdr struct {
-       Len          uint64
-       Level        int32
-       Type         int32
-       X__cmsg_data [0]uint8
+       Len   uint64
+       Level int32
+       Type  int32
 }
 
 type Inet4Pktinfo struct {
index 915ca95190e8be87685cd3c379eb7151413da072..de817f50afbbbe33fe514267a3a1c7ed95949937 100644 (file)
@@ -244,10 +244,9 @@ type Msghdr struct {
 }
 
 type Cmsghdr struct {
-       Len          uint64
-       Level        int32
-       Type         int32
-       X__cmsg_data [0]uint8
+       Len   uint64
+       Level int32
+       Type  int32
 }
 
 type Inet4Pktinfo struct {
index a1180553ec6f38aaa5be3b09066ba8cd756b3da6..e75d8e3925ed05446b65d7d9e12cb12135970818 100644 (file)
@@ -244,10 +244,9 @@ type Msghdr struct {
 }
 
 type Cmsghdr struct {
-       Len          uint64
-       Level        int32
-       Type         int32
-       X__cmsg_data [0]uint8
+       Len   uint64
+       Level int32
+       Type  int32
 }
 
 type Inet4Pktinfo struct {