aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2018-12-05 12:21:05 +0100
committerLukas Larsson <[email protected]>2018-12-05 12:22:17 +0100
commitf9dab18e922c00e51b945da2052cd513d3cd39df (patch)
tree7f2f2ccc798ebb65c4626c5f6167fdbabdb692e9 /erts/emulator
parentf37c8b37f49034fe10898ea47ed9c043ad2ba173 (diff)
downloadotp-f9dab18e922c00e51b945da2052cd513d3cd39df.tar.gz
otp-f9dab18e922c00e51b945da2052cd513d3cd39df.tar.bz2
otp-f9dab18e922c00e51b945da2052cd513d3cd39df.zip
erts: Fix inet pktopts on very old linux kernels
Diffstat (limited to 'erts/emulator')
-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 4c1ab90c01..44b0dcea1d 100644
--- a/erts/emulator/drivers/common/inet_drv.c
+++ b/erts/emulator/drivers/common/inet_drv.c
@@ -633,9 +633,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