[Python-checkins] r45714 - python/trunk/Modules/socketmodule.c

thomas.wouters python-checkins at python.org
Tue Apr 25 17:08:11 CEST 2006


Author: thomas.wouters
Date: Tue Apr 25 17:08:10 2006
New Revision: 45714

Modified:
   python/trunk/Modules/socketmodule.c
Log:

Fix SF bug #1476111: SystemError in socket sendto. The AF_INET6 and
AF_PACKET cases in getsockaddrarg were missing their own checks for
tuple-ness of the address argument, which means a confusing SystemError was
raised by PyArg_ParseTuple instead.



Modified: python/trunk/Modules/socketmodule.c
==============================================================================
--- python/trunk/Modules/socketmodule.c	(original)
+++ python/trunk/Modules/socketmodule.c	Tue Apr 25 17:08:10 2006
@@ -1217,6 +1217,14 @@
 		int port, flowinfo, scope_id, result;
  		addr = (struct sockaddr_in6*)&(s->sock_addr).in6;
 		flowinfo = scope_id = 0;
+		if (!PyTuple_Check(args)) {
+			PyErr_Format(
+				PyExc_TypeError,
+				"getsockaddrarg: "
+				"AF_INET6 address must be tuple, not %.500s",
+				args->ob_type->tp_name);
+			return 0;
+		}
 		if (!PyArg_ParseTuple(args, "eti|ii", 
 				      "idna", &host, &port, &flowinfo,
 				      &scope_id)) {
@@ -1319,6 +1327,14 @@
 		char *haddr = NULL;
 		unsigned int halen = 0;
 
+		if (!PyTuple_Check(args)) {
+			PyErr_Format(
+				PyExc_TypeError,
+				"getsockaddrarg: "
+				"AF_PACKET address must be tuple, not %.500s",
+				args->ob_type->tp_name);
+			return 0;
+		}
 		if (!PyArg_ParseTuple(args, "si|iis#", &interfaceName,
 				      &protoNumber, &pkttype, &hatype,
 				      &haddr, &halen))


More information about the Python-checkins mailing list