]> granicus.if.org Git - python/commitdiff
Fix SF bug #1476111: SystemError in socket sendto. The AF_INET6 and
authorThomas Wouters <thomas@python.org>
Tue, 25 Apr 2006 15:08:10 +0000 (15:08 +0000)
committerThomas Wouters <thomas@python.org>
Tue, 25 Apr 2006 15:08:10 +0000 (15:08 +0000)
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.

Modules/socketmodule.c

index 39a0240c5c3c7ace2d40d98919e399655b2d0b60..b77f41e9b248158688e849d7e34e968898b262ea 100644 (file)
@@ -1217,6 +1217,14 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
                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 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
                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))