sassanp / pynetinfo

Python module for retrieving network information
http://pypi.python.org/pypi/pynetinfo/
GNU General Public License v2.0
11 stars 10 forks source link

Fix file and socket leak #3

Open yangjian opened 11 years ago

tsdunc commented 10 years ago

Patch...

diff --git a/sources/opensource/Pynetinfo-0.2.3/iface.c b/sources/opensource/Pynetinfo-0.2.3/iface.c index f5b50ba..5f52fd7 100644 --- a/sources/opensource/Pynetinfo-0.2.3/iface.c +++ b/sources/opensource/Pynetinfo-0.2.3/iface.c @@ -55,6 +55,7 @@ PyObject netinfo_list_active_devs(PyObject self, PyObject *args) ret = ioctl(fd, SIOCGIFCONF, &ifc); if (ret < 0) { PyErr_SetFromErrno(PyExc_Exception);

@@ -93,32 +95,40 @@ PyObject netinfo_get_addr(PyObject self, PyObject args, int cmd) char dev; struct sockaddr_in *sin; char hwaddr[18];

@@ -223,8 +241,10 @@ PyObject netinfo_set_addr(PyObject self, PyObject *args, int cmd) ret = ioctl(fd, cmd, &ifreq, sizeof(struct ifreq)); if (ret < 0) { PyErr_SetFromErrno(PyExc_Exception);

diff --git a/sources/opensource/Pynetinfo-0.2.3/route.c b/sources/opensource/Pynetinfo-0.2.3/route.c index 94e6b6f..5d56a4c 100644 --- a/sources/opensource/Pynetinfo-0.2.3/route.c +++ b/sources/opensource/Pynetinfo-0.2.3/route.c @@ -45,8 +45,10 @@ PyObject _netinfo_adddel_route(PyObject self, PyObject args, int action) return NULL; } ret = PyArgParseTuple(args, "ssss", &dev, &dest, &gateway, &netmask); / parse argument */

@@ -102,6 +106,7 @@ PyObject netinfo_get_routes(PyObject self, PyObject *args) } if (!fgets(buffer, 1024, file)) { PyErr_SetFromErrno(PyExc_Exception);