git » pytipc » commit 42a03de

Initialize big integers to avoid corruption.

author Alberto Bertogli
2008-01-12 20:27:09 UTC
committer Alberto Bertogli
2008-01-12 20:43:24 UTC
parent 782d5a5a38105a17e929e9bde25b1290f3b60a04

Initialize big integers to avoid corruption.

PyArg_ParseTuple's i/I seems to use "int", so if you give a larger type of
integer (uint64_t, for instance), there is no warantee the high part will
be 0, and can cause corruption.

This patch initializes all integers potentially bigger than an int to
avoid that problem.

Signed-off-by: Alberto Bertogli <albertito@gmail.com>

tipc_ll.c +3 -3

diff --git a/tipc_ll.c b/tipc_ll.c
index 8950daa..a6206fd 100644
--- a/tipc_ll.c
+++ b/tipc_ll.c
@@ -180,7 +180,7 @@ static PyObject *tipc_sendto(PyObject *self, PyObject *args)
 {
 	int fd, rv;
 	char *buf;
-	size_t len;
+	size_t len = 0;
 	struct sockaddr_tipc sa;
 	PyObject *addr;
 
@@ -204,7 +204,7 @@ static PyObject *tipc_recvfrom(PyObject *self, PyObject *args)
 {
 	int fd;
 	char *buf;
-	size_t maxlen;
+	size_t maxlen = 0;
 	struct sockaddr_tipc sa;
 	socklen_t salen = sizeof(sa);
 	int rv;
@@ -256,7 +256,7 @@ static PyObject *tipc_build_subscr(PyObject *self, PyObject *args)
 static PyObject *tipc_parse_event(PyObject *self, PyObject *args)
 {
 	unsigned char *buf;
-	size_t len;
+	size_t len = 0;
 	struct tipc_event *event;
 
 	if (!PyArg_ParseTuple(args, "s#:tipc_parse_event",