aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/drivers/common/inet_drv.c
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2018-12-21 11:58:08 +0100
committerLukas Larsson <[email protected]>2018-12-21 11:58:08 +0100
commit55bf32b64e1a4bbed588544077a109fc07e1f02d (patch)
tree005d54c398933018caf37df69313602cd2bb8bf7 /erts/emulator/drivers/common/inet_drv.c
parent58dcd66ac638b1d6355662f0fb364001013769f4 (diff)
parentf9dab18e922c00e51b945da2052cd513d3cd39df (diff)
downloadotp-55bf32b64e1a4bbed588544077a109fc07e1f02d.tar.gz
otp-55bf32b64e1a4bbed588544077a109fc07e1f02d.tar.bz2
otp-55bf32b64e1a4bbed588544077a109fc07e1f02d.zip
Merge branch 'lukas/erts/inet_pktopts_old_linux/OTP-15494' into maint
* lukas/erts/inet_pktopts_old_linux/OTP-15494: erts: Fix inet pktopts on very old linux kernels
Diffstat (limited to 'erts/emulator/drivers/common/inet_drv.c')
-rw-r--r--erts/emulator/drivers/common/inet_drv.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/erts/emulator/drivers/common/inet_drv.c b/erts/emulator/drivers/common/inet_drv.c
index 47eb5df7dd..b44464d6da 100644
--- a/erts/emulator/drivers/common/inet_drv.c
+++ b/erts/emulator/drivers/common/inet_drv.c
@@ -634,9 +634,13 @@ static size_t my_strnlen(const char *s, size_t maxlen)
* header length. To get the header length we use
* the pointer difference from the cmsg start pointer
* to the CMSG_DATA(cmsg) pointer.
+ *
+ * Some platforms (seen on ppc Linux 2.6.29-3.ydl61.3)
+ * may return 0 as the cmsg_len if the cmsg is to be ignored.
*/
#define LEN_CMSG_DATA(cmsg) \
- ((cmsg)->cmsg_len - ((char*)CMSG_DATA(cmsg) - (char*)(cmsg)))
+ ((cmsg)->cmsg_len < sizeof (struct cmsghdr) ? 0 : \
+ (cmsg)->cmsg_len - ((char*)CMSG_DATA(cmsg) - (char*)(cmsg)))
#define NXT_CMSG_HDR(cmsg) \
((struct cmsghdr*)(((char*)(cmsg)) + CMSG_SPACE(LEN_CMSG_DATA(cmsg))))
#endif