From 2479126376e44050c43c93b92d4efb23bb6d160c Mon Sep 17 00:00:00 2001 From: Oleksii Shevchuk Date: Tue, 9 Oct 2018 11:48:29 +0300 Subject: [PATCH] Fix https://github.com/giampaolo/psutil/issues/1346 --- psutil/_psutil_sunos.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/psutil/_psutil_sunos.c b/psutil/_psutil_sunos.c index 99069f56a..0717f1950 100644 --- a/psutil/_psutil_sunos.c +++ b/psutil/_psutil_sunos.c @@ -1173,7 +1173,7 @@ psutil_net_connections(PyObject *self, PyObject *args) { mibhdr.len = 0; #endif memcpy(buf, &tor, sizeof tor); - memcpy(buf + sizeof tor, &mibhdr, sizeof mibhdr); + memcpy(buf + tor.OPT_offset, &mibhdr, sizeof mibhdr); ctlbuf.buf = buf; ctlbuf.len = tor.OPT_offset + tor.OPT_length; @@ -1213,6 +1213,9 @@ psutil_net_connections(PyObject *self, PyObject *args) { goto error; } + memset(&mibhdr, 0x0, sizeof(mibhdr)); + memcpy(&mibhdr, buf + toa.OPT_offset, toa.OPT_length); + databuf.maxlen = mibhdr.len; databuf.len = 0; databuf.buf = (char *)malloc((int)mibhdr.len);